Urgent Help Needed with Variable Range

GA81848

Board Regular
Joined
Apr 25, 2005
Messages
124
I need some help with a variable range in which both the start point and end point can change.

To give you an example I have data in cells B55:D100. Extra rows can be inserted either above this range or within it. To give an example:-

If a row is inserted at line 23, my data then moves to B56:D101.

I've tried using something like this but am getting lost with it:-

Dim LastRow1 As Long
Dim LastRow2 As Long

LastRow1 = Range("B5000").End(xlUp).Row
MsgBox LastRow1
LastRow2 = Range(lastrow1).End(xlUp).Row
MsgBox LastRow2

Can anyone help?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Why not give B55:D101 a named range?

Then you can refer to the named range in your VBA. Excel will take care of the inserted rows for you.
 
Upvote 0

Forum statistics

Threads
1,214,608
Messages
6,120,500
Members
448,968
Latest member
screechyboy79

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