Pasting to Dynamic cell using Offset.

JohnZ1156

Board Regular
Joined
Apr 10, 2021
Messages
182
Office Version
  1. 2021
Platform
  1. Windows
I have a VBA Macro to paste a range to a specific cell, but now, I would like it to paste that range to the cell 4 rows below the last cell with data in column A.

Here's sort of what I'm talking about.

Before, I specified Cell A23. The last cell in column A with data is A19.

I know that I have to select a cell in column A way down at the bottom (A65536), then End(xlUp).Select
That takes me to Cell A19.
Then, how do I work an Offset(4,0) into this line of code where A23 is?

Sheets("PrintSOF").Range("A23").PasteSpecial xlPasteValues
Sheets("PrintSOF").Range("A23").PasteSpecial xlPasteFormats
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
paste that range to the cell 4 rows below the last cell with data in column A

Maybe...
VBA Code:
    With Sheets("PrintSOF").Cells(Rows.Count, "A").End(xlUp).Offset(4)
        .PasteSpecial xlPasteValues
        .PasteSpecial xlPasteFormats
    End With

You definitely do not need the .Select

BTW 65536 is not the bottom row in Excel 2021
 
Upvote 0
Solution
Hi Mark858,
Thank you for your help. I wasn't sure exactly how to combine the Offset command into my existing command.
Works great !!!
And yes, I will increase the last row of 65536.

Thanks again, I appreciate your help.
John
 
Upvote 0

Forum statistics

Threads
1,226,695
Messages
6,192,483
Members
453,727
Latest member
tuong_ng89

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