|
-
Aug 23rd, 2005, 01:02 PM
#1
Thread Starter
Junior Member
[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
-
Aug 23rd, 2005, 01:53 PM
#2
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 23rd, 2005, 11:27 PM
#3
Thread Starter
Junior Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|