0

My VBA code is set to copy a value from one sheet (NB this value will change each time the sheet is open) and paste into a 'database' on the next available row.

Think I've got it right but the Paste method seems to fail, can anyone see why?

Windows("Invoice Program.xlsm").Activate
Range("B4").Select
Application.CutCopyMode = False
Selection.Copy
Workbooks.Open ("C:\Users\Invoice Database.xlsx")
Windows("Invoice Database.xlsx").Activate
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Selection.Paste
A Anderson
  • 15
  • 2
  • 5

2 Answers2

0
Dim varTemp as Variant

Windows("Invoice Program.xlsm").Activate
Range("B4").Select
varTemp = ActiveCell.Value
Workbooks.Open ("C:\Users\Invoice Database.xlsx")
Windows("Invoice Database.xlsx").Activate
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveCell = varTemp
0

Use ActiveSheet.Paste but in the line before use DoEvents.

DoEvents
ActiveSheet.Paste
dasg7
  • 46
  • 8