Select row 1 down to the last row with information

gberg

Board Regular
Joined
Jul 16, 2014
Messages
180
Office Version
  1. 365
Platform
  1. Windows
I am looking for a way to select information in Columns A, B & C from row 1 down to the last row with information in these columns.

There is information in Columns A, B and C.
- Many of the rows have information but not all rows, there are many blank rows
- At most the rows with information will only be up to row 5,000
- The number of rows with blanks from the first row to the last row with info will vary greatly from each instance this macro is run

I am trying to select from A1:Cxxxx (Cxxxx being the last row with data in in)
- If there is something in Column A, Column B & C will also have info in it
- If there is nothing in Column A then likewise Column B & C will not have info in it.


I have tried this:

Range("A1:C50000").Select
Range(Selection, Selection.End(xlUp)).Select

This just keeps the A1:C50000 selected.

Hope someone can help
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
VBA Code:
Range("A1:C" & Cells(rows.count,"C").end(xlup).Row).Select
 
Upvote 0
Solution
And like that you make it so easy!!!!!!! That works great, thank you for the help.

Greg
 
Upvote 0
And like that you make it so easy!!!!!!! That works great, thank you for the help.

Greg
If your using this as part of a script your writing. Tell us what else you plan to do. Normally you do not need to select a range. Selecting is common but in most cases not needed.
 
Upvote 0
I have many things going on with the script, the selection is needed
 
Upvote 0
I have many things going on with the script, the selection is needed
Most of the time, you actually do not need to select the range in order to work with (you can just reference it).
And the more "Selects" you have in your code, the slower it will run.
 
Upvote 0
Sort of like this:
Without using select:
VBA Code:
Range("A1:C" & Cells(Rows.Count, "C").End(xlUp).Row).Copy Sheets(2).Range("A1")
 
Upvote 0
Another popular technique is to set a range variable, i.e.
VBA Code:
Dim rng as Range
Set rng = Range("A1:C" & Cells(Rows.Count,"C").End(xlUp).Row)

Then you can reference it in other parts of your code easily, i.e.
VBA Code:
rng.Copy
or if you wanted to do a bunch of formatting this to the range, you could do them all at once with a "With" statement, i.e.
VBA Code:
With rng
    .Font.Bold = True
    .Font.Color = -16776961
End With
This can be a great shortcut if you are referencing this range numerous times in your code.
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

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