![]() |
Selecting non-adjacent rows
How do I programmatically select non-adjacent rows, in
order to change the format? |
Selecting non-adjacent rows
Jon
Here's one way: Sub test() Dim FormatRange As Range With Sheets("Sheet1") Set FormatRange = Union(.Rows(3), .Rows(6), .Rows(9)) FormatRange.Interior.ColorIndex = 3 End With End Sub -- Best Regards Leo Heuser MVP Excel Followup to newsgroup only please. "Jon" skrev i en meddelelse ... How do I programmatically select non-adjacent rows, in order to change the format? |
Selecting non-adjacent rows
I usually built up a range using Union and then select it:
Sub a() Dim Counter As Integer Dim Rg As Range Set Rg = ActiveCell For Counter = 1 To 10 Set Rg = Union(Rg, ActiveCell.Offset(Counter * 2)) Next Rg.Select End Sub -- Jim Rech Excel MVP |
Selecting non-adjacent rows
Jon, here is one way
Range("2:2,6:6,11:11,16:16,20:20").NumberFormat = "0.00_);[Red](0.00)" -- Paul B Always backup your data before trying something new Using Excel 97 & 2000 Please post any response to the newsgroups so others can benefit from it ** remove news from my email address to reply by email ** "Jon" wrote in message ... How do I programmatically select non-adjacent rows, in order to change the format? |
All times are GMT +1. The time now is 10:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com