realniceguy5000
Board Regular
- Joined
- Aug 19, 2008
- Messages
- 148
Hi, I have an odd problem I have used this method in the past to loop though a range of cells however this time it is not working.
Here is the part that is causing the issue.
The code should select AG2 and work down to the lastrow with data. Last row picks the correct lastrow but Cell. select picks Cell AG2100 to start?
Any Ideas: Thank You, Mike
Here is the part that is causing the issue.
Code:
Sub Sortme()
Dim R As Range
Dim Cell As Object
Dim Lastrow As Long
Dim S As String
Lastrow = Range("AG65000").End(xlUp).Row
Set R = Range("AG2" & Lastrow)
For Each Cell In R
Cell.Select 'remove after
S = Cell.Value
S = Left(Cell, 20)
Next Cell
End Sub
The code should select AG2 and work down to the lastrow with data. Last row picks the correct lastrow but Cell. select picks Cell AG2100 to start?
Any Ideas: Thank You, Mike