[RESOLVED] Working with Selected Rows Only??
I'm trying to get my macro to act on the selected rows only, as compared to running through all rows from top to bottom. Is there a way to check the status of the row as the activecell moves down the spreadsheet? If not selected then go to next row and check again. THANKS.
For example:
Sub Loop_Selected_Rows()
Range("A1").Select
For x = 1 To NumRows
ActiveCell.Offset(1, 0).Activate
' I assumed using .select would unselect the selected rows. Not sure if activate would work
'If row is selected Then
' do stuff here
'End If
Next x
End Sub
Re: Working with Selected Rows Only??
Yes, the .Activate will also deselect any rows that have been selected.
You can have only one, either a selection or an active cell at a time. ;)
Re: [RESOLVED] Working with Selected Rows Only??
Found a way around it!! Here:
Private Sub Run_Selected_Info()
i = 1
x = 1
Dim RowArray(1000) As Integer
For Each RW In Selection.Rows
RowArray(i) = RW.Row
i = i + 1
Next RW
Do While RowArray(x) <> 0
Cells(RowArray(x), 1).Select
' Call some function here
x = x + 1
Loop
End Sub