dynamic copy and paste values into workbook

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
443
Office Version
  1. 2016
Hey guys,

Im trying to build a list of imported bills into a new workbook. This workbook will become increasingly larger and large of a list as we import new bills each day. I need to to select from the active workbook and select the active rows and copy and paste into the same workbook each time, but I need the data to grow and grow each time. Here is what I have so far from recording maybe im going about this the wrong way. What are your thoughts?

Sub copypaste()
'
' copypaste Macro
'


'
Workbooks.Open Filename:="A:\Imported Entries\Ademero\Historical imports.xls"

Windows("Approval process (12).csv").Activate
'I need this to be based on active workbook and not be that particular workbook name because it changes each time
ActiveWindow.SmallScroll Down:=-48
Range("E5").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("Historical imports.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Windows("Approval process (12).csv").Activate
End Sub

THANKS!
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try this:
Code:
Sub CopyPaste()

Dim wb1 As Workbook
Dim wb2 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lrow As Long
Dim lrow As Long
Dim rngstr As String
Dim rng As Range

rngstr = Selection.Address

Set wb1 = ActiveWorkbook
Set ws1 = ActiveSheet
Set rng = ws1.Range(rngstr)

Set wb2 = Workbooks.Open("A:\Imported Entries\Ademero\Historical imports.xls")
Set ws2 = wb2.Sheets(1)
lrow = ws2.Cells(Rows.Count, 1).End(xlUp).Row

rng.EntireRow.Copy Destination:=ws2.Cells(lrow, 1)
Application.CutCopyMode = False

End Sub
 
Last edited:
Upvote 0
thanks for this. For some reason it was erroring(is this not a word?) out. I actually figured I could use a simpler code. I just need it to copy the active cells values on sheet1(only the data that is there, ie not the whole sheet) and paste them to sheet2 after the prior data.
 
Upvote 0
sorry i made it seem like i already had the code. I am still at a loss with this one and still need help. I know its a simple fix, but I cant seem to figure it out. I just want all the data copied and pasted from sheet1 (values) on to sheet2 and i want it to paste the new data in the empty cells so that it doesn't erase the old data.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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