Selection of rows (variable)

cmazur71

Board Regular
Joined
Aug 7, 2003
Messages
63
I want to select a group of rows, depending on how many are in my spreadsheet
I set 'a' to equal the number of rows...now I need to select rows 2 thru a, but I cannot figure out the formatting. How do I do this?

a = Worksheets("Final").Cells(Rows.Count, 1).End(xlUp).Row
Rows("2:" & a).Select
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
How about
VBA Code:
Dim a As Long
Worksheets("Final").Select
a = Cells(Rows.Count, 1).End(xlUp).Row
Rows("2:" & a).Select
 
Upvote 0
Solution
How about
VBA Code:
Dim a As Long
Worksheets("Final").Select
a = Cells(Rows.Count, 1).End(xlUp).Row
Rows("2:" & a).Select
I'm getting an error when i get to the Rows command: Run Time Error 1004 Select Method of Range class failed:

Dim endrow As Long
Worksheets("Final").Range("A1").Select
endrow = Cells(Rows.Count, 1).End(xlUp).Row
Rows("2:" & endrow).Select
 
Upvote 0
This line
VBA Code:
Worksheets("Final").Range("A1").Select
should be
VBA Code:
Worksheets("Final").Select
 
Upvote 0

Forum statistics

Threads
1,214,390
Messages
6,119,235
Members
448,879
Latest member
VanGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top