I am new to excel macros. I have created this macro that transfer data to another excel file. However, after transferring the file it should clear the content from old sheet which I am not able to fix I get an error. Below is my code this will transfer data properly after that it stops and debugs at the below statement. Please help, after transferring data I want to clear content in old excel from where it has copied the data. Set ws = Workbooks("Path Old WorkBook").Worksheets("Sheet2").Range("A2").ClearContents
Private Sub CommandButton2_Click()
Dim InvoiceNumber As String
Dim ForwarderCode As String
Dim Status As String
Dim wb As Workbook
Dim ws As Workbook
Worksheets("Sheet2").Select
InvoiceNumber = Range("A2")
Worksheets("SampleFile").Select
ForwarderCode = Range("B2")
Worksheets("SampleFile").Select
Status = Range("C2")
Set wb = Workbooks.Open("Path")
Worksheets("Sheet2").Select
Worksheets("Sheet2").Range("A2").Select
RowCount = Worksheets("Sheet2").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Sheet2").Range("A1")
.Offset(RowCount, 0) = InvoiceNumber
.Offset(RowCount, 1) = ForwarderCode
.Offset(RowCount, 2) = Status
End With
wb.Save
Set ws = Workbooks("Path Old WorkBook").Worksheets("Sheet2").Range("A2").ClearContents
Set ws = Workbooks("Path Old WorkBook").Worksheets("Sheet2").Range("B2").ClearContents
Set ws = Workbooks("Path Old WorkBook").Worksheets("Sheet2").Range("C2").ClearContents
End Sub