Select Everything until empty row

Lorlai

Board Regular
Joined
May 26, 2011
Messages
85
I have some VBA code that I am trying to use. I want to select all data from row A1 until the last used cell before an empty row. For instance, I want to be able to select the Range A1:Z100 without knowing that the last piece of data is in Z100. How can I do this in VBA?

Additionally, how can I take this new found range and store it so I can put it into this line of code:

Code:
wsnew.Range([COLOR=Red]Need to Put Range Here[/COLOR]).Offset(, wsnew.Cells(1, Columns.Count).End(xlToLeft).Column + 2).Formula = "=IF(A1=A203,A1,""!"" & A1)"

Thank you for your help!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Here's one way:

Dim LR as Long
LR = Cells(Rows.count,"A").End(xlup).Row
Range("A1:Z" & LR)...

HTH,
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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