Copy & pasting variable range value below

ahuang3433

New Member
Joined
Jan 24, 2017
Messages
39
I have this code where I use an input box to input data to first empty cell in Column A. After the data is input into the cell, I want to use Column "E" as my last row reference point to copy and paste the value I've input in Column A to the last row based on Column "E" reference. Current code only copy from A51:A52 but I need it to copy from A51:A56. This range can vary based on data.

VBA Code:
ActiveSheet.Range("A1").End(xlDown).Offset(1, 0) = InputBox("Enter ESR#", "InputBox Example")
    Dim lastRow As Long
    lastRow = Range("E" & Rows.count).End(xlDown).Row
    Range("A1").End(xlDown).Copy Destination:=Range("A" & lastRow).End(xlUp).Offset(1, 0)
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
How about
VBA Code:
With Range(Range("A1").End(xlDown).Offset(1, 0), Range("E" & Rows.Count).End(xlUp).Offset(, -4))
   .Value = InputBox("Enter ESR#", "InputBox Example")
End With
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,548
Members
449,170
Latest member
Gkiller

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