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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,351
Messages
6,124,445
Members
449,160
Latest member
nikijon

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