nc_waggoner
New Member
- Joined
- Sep 2, 2016
- Messages
- 21
Good morning,
I have a workbook with 3 sheets of similar format. Each returns data starting in cell "P3:W" but can return a different number of rows on each sheet. For example, SheetA returned 5 rows so I would need to select "P3:W7" but on SheetB there is only one row so I only need to select "P3:W3". I was using the below code which worked for SheetA but selected far too many rows on SheetB:
Dim r As Long
r = Selection.End(xlDown).Row
Range("P" & Selection.Row, "W" & r).Select
2 thoughts...is there a code to select any range? Or is there a code to reference a "counter" cell (ex. Cell Z1) and select that many rows.
I have a workbook with 3 sheets of similar format. Each returns data starting in cell "P3:W" but can return a different number of rows on each sheet. For example, SheetA returned 5 rows so I would need to select "P3:W7" but on SheetB there is only one row so I only need to select "P3:W3". I was using the below code which worked for SheetA but selected far too many rows on SheetB:
Dim r As Long
r = Selection.End(xlDown).Row
Range("P" & Selection.Row, "W" & r).Select
2 thoughts...is there a code to select any range? Or is there a code to reference a "counter" cell (ex. Cell Z1) and select that many rows.