Dynamic Ranges

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
I have the statement below that I hardcoded the values I165:L165.

Each time I create this report I have to change the values (165 to the last row).

Is there a way to dynamically change them using xlUp since the column IXXX is the last row in column I and the L165 is the same row just over 4 cells.

Thanks


sourceBook.Sheets("Services").Range("I165:L165").Copy


Thanks
 

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
Code:
sourceBook.Sheets("Services").Range("I" & Rows.Count).End(xlUp).Resize(, 4).Copy
 
Upvote 0
how would one modify this statement to get the cell info 4 rows above this range.

I tried something like this

sourceBook.Sheets("Services").Range("I" & Rows.Count).End(xlUp).Resize(, 4).Copy <- orginal
sourceBook.Sheets("Services").Range("I" & Rows.Count - 4).End(xlUp).Resize(, 4).Copy

Thanks
 
Upvote 0
Try
Code:
sourceBook.Sheets("Services").Range("I" & Rows.Count).End(xlUp).Offset(-4).Resize(, 4).Copy
 
Upvote 0
My pleasure & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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