I have a problem. I need to write the macro which select the values in column E. Values of selected items should be between values in cell T2 and U2. After selection, macro should draw the chart.
I tried 3 ways:
First Approach:
Sub wykres1()  
    Dim rng As Range
    Dim cell As Range 
    Set rng = Range("E1", Range("E65536").End(xlUp))  
    For Each cell In rng  
    If cell.Value > "T2" and cell.value < "U2" Then Cell.Select    
        With Selection    
            ActiveSheet.Shapes.AddChart2    
        End With    
    Next cell    
End Sub
Wykres1 Doesn't work, because the line with
ifis highlighted on red.
Second Approach:
Sub wykres2()    
    Dim rng As Range    
    Dim cell As Range    
    Set rng = Range("E1", Range("E65536").End(xlUp))    
    For Each cell In rng    
        If cell.Value > ActiveSheet.Cell(2,20).Value and cell.value < ActiveSheet.Cell(2,21).Value Then Cell.Select    
        With Selection    
            ActiveSheet.Shapes.AddChart2    
        End With    
    Next cell
End Sub
Wykres2 Doesn't work, because the line with
ifis highlighted on red.
Third Approach:
Sub wykres3()     
    Dim rng As Range
    Dim cell As Range
    Set rng = Range("E1", Range("E65536").End(xlUp))
    For Each cell In rng
        If cell.value > -35 And cell.value < -32 Then cell.Select
        With Selection
            ActiveSheet.Shapes.AddChart2    
        End With
    Next cell
End Sub
Wykres3 freeze after run. When I remove the part with draw chart, the macro select one cell not the range with selected values. And here I put the values in macro (-35) (-32) - but I'm interested in possibility to put values from cells (T2) (U2).
As I mentioned - I need to create macro which select the cells in column E with values between values in cells T2 and U2. After selection macro must draw the chart.
Thank You for Your help.
 
     
    