Hello all
Hope someone can help with this - Please can I have some VB code that will select all rows in columns H2:M2, when I don't know each time where the last row will be? I'm guessing this is a dynamic range, but not sure!
Thank you
Helen
Hello all
Hope someone can help with this - Please can I have some VB code that will select all rows in columns H2:M2, when I don't know each time where the last row will be? I'm guessing this is a dynamic range, but not sure!
Thank you
Helen
Last edited by HelenW; 12-11-2008 at 06:20 AM.
The macro recorder provided this :Sub Macro1()
![]()
Sub Macro1() Range("h2:m2").Select Range(Selection, Selection.End(xlDown)).Select End Sub
Perfect, thanks! Most note that one down somewhere for future reference...
It's mimicking this action: select the first cells and press the down arrow while holding down the ctrl+shift keys
You don't need to select ranges in VBA as a rule.
If the range has empty rows & columns around it you could use CurrentRegion![]()
Dim rng As Range Set rng = ActiveSheet.Range(Cells(2, 8), Cells(Rows.Count, 13).End(xlUp)) 'e.g rng.Copy
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Thank you for this - I haven't yet got my head round "dim" and all that though! Can you please advise what the numbers (2, 8 and 13) apply to?
The numbers are references to Row & column (R1C1), so Cells(1,1) is A1
Wonderful - I'll give that a go, thanks. Do I need to use the rng.copy if I don't need to copy it? Just need to select the range.
Sorry - it only selects the first 2 columns in the range! Any ideas?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks