Format

Ody

Board Regular
Joined
Oct 14, 2010
Messages
215
Good day all,

I'm trying to right some code that will format the data I have starting in row 8 and going to the last row of data in my table (which is always different). I get the VB for formatting, I'm just stuck on how to write the dynamic part of the code, if that makes sense.

Appreciate any assistance.

Thanks!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try:

Code:
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A7:R" & LR).Select
 
Upvote 0
Above is the legit answer, I have a backwoods way of selecting the first open cell for future reference.

If I have to refer to next open cell in a column, I use this:
Code:
Columns("A:A").Select
    Range("A65536").End(xlUp).Offset(1, 0).Select
selects the very last cell in the column and then goes up to the first cell with data in it, then moves down one...if that makes sense.
 
Upvote 0
Above is the legit answer, I have a backwoods way of selecting the first open cell for future reference.

If I have to refer to next open cell in a column, I use this:
Code:
Columns("A:A").Select
    Range("A65536").End(xlUp).Offset(1, 0).Select
selects the very last cell in the column and then goes up to the first cell with data in it, then moves down one...if that makes sense.

I would highly recommend changing that code to:
Code:
Range("A" & Rows.Count).End(xlUp).Offset(1,0).Select
By using Rows.Count instead of hardcoding the last cell, it gives you more universal compatability if you were to import the code into 2007 or 2010 (since they have more rows than 2003 and older).
 
Upvote 0
I would highly recommend changing that code to:
Code:
Range("A" & Rows.Count).End(xlUp).Offset(1,0).Select
By using Rows.Count instead of hardcoding the last cell, it gives you more universal compatability if you were to import the code into 2007 or 2010 (since they have more rows than 2003 and older).
Thanks for the tip!
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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