0
votes

Sub Macro5() ' ' Macro5 Macro '

'
Dim wbk As Workbook
Application.ScreenUpdating = False

Set wbk = Workbooks.Open("g:\Work\EU Personal Assignment.xlsx")
    Range("O2:R2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Windows("Dashboard_for_Roshan.xlsm").Activate
    Range("A65536").End(xlUp).Select
    ActiveSheet.Paste
    Windows("EU Personal Assignment.xlsx").Activate
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy


    Windows("Dashboard_for_Roshan.xlsm").Activate
    Range("E65536").End(xlUp).Select
    ActiveSheet.Paste
    Windows("EU Personal Assignment.xlsx").Activate
    Range("AC2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy

    Windows("Dashboard_for_Roshan.xlsm").Activate
    Range("F65536").End(xlUp).Select
    ActiveSheet.Paste



Call .wbk.Close(False) <- i get the error here 


End Sub

Prior to the excel End(xlUp) i was using

Cells(Cells(Rows.Count, "A").End(xlUp).Row + 1, "A").Select

but i was unable to paste data using this.

Edit: the error was an extra . before .wbk but now it replaces the previous row data, whereas i want it to paste data below the last used row any advice?

Cheers Mathew

1
the posted code is irrelevant to what you are asking. Try Range("A" & Range("A" & Rows.count).End(xlup).ROw+1).Value = "last cell + 1" - user2140173
hello mehow, actually this was the original error i was getting which i fixed. thanks - mathew

1 Answers

0
votes

To paste below the data you need to select the row 1 below your data before you paste

To use the same method as you try:

Range("A65536").End(xlUp).Offset(1, 0).Select

Or as an alternative method try:

Cells(ActiveSheet.UsedRange.Rows.Count + 1, 1).Select

To fix your error try using this:

wbk.Close