Dear Expert,
Currently I have hardcoded the destination sheets to be "Cashbook" whereby the data will be copied to. If I need user to input the destination sheet, how do I code the macro?
Dim lr As Long, r As Long
Dim ws As Worksheet
Dim wsName As String
Dim wsDest As String
wsName = Sheets("Instruction").Range("H4")
On Error Resume Next
Set ws = Sheets(wsName)
On Error GoTo 0
If ws Is Nothing Then
MsgBox wsName & " is not a valid sheet name for this workbook"
Else
With ws
UsedRange.Copy Destination:=Sheets("Cashbook").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
End If
End Sub
Currently I have hardcoded the destination sheets to be "Cashbook" whereby the data will be copied to. If I need user to input the destination sheet, how do I code the macro?
Dim lr As Long, r As Long
Dim ws As Worksheet
Dim wsName As String
Dim wsDest As String
wsName = Sheets("Instruction").Range("H4")
On Error Resume Next
Set ws = Sheets(wsName)
On Error GoTo 0
If ws Is Nothing Then
MsgBox wsName & " is not a valid sheet name for this workbook"
Else
With ws
UsedRange.Copy Destination:=Sheets("Cashbook").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
End If
End Sub