Team,
I have tried debugging the below code and cannot find any issue, but it keeps failing with a 1004 error: Paste method of worksheet class failed.
The code works until it gets to the "ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B2:B500") ' works with column B" line. Then fails.Thank you for any help.
Option Explicit
Dim fullPath As String
Private Sub FileOpenDialogBox()
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1
.Show
fullPath = .SelectedItems.Item(1) 'Set file paths for the SN report and the current Yearbook version
End With
End Sub
Private Sub GetSNReport() ' Open The SN ID Report and Copy Column A then close the report
Dim erow
FileOpenDialogBox
Do While Len(fullPath) > 0
If fullPath = "Weekly comparison.xlsm" Then
Exit Sub
End If
'Open file once found
Workbooks.Open (fullPath)
Sheets("Page 1").Select
Range("A3:A501").Copy
ActiveWorkbook.Save
ActiveWorkbook.Close
'Workbooks("Weekly comparison.xlsm").Activate
'Worksheets("Sheet1").Activate
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B2:B500") ' works with column B
fullPath = fullPath
Loop
fullPath = fullPath
MsgBox ("GetSNReport complete")
End Sub
I have tried debugging the below code and cannot find any issue, but it keeps failing with a 1004 error: Paste method of worksheet class failed.
The code works until it gets to the "ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B2:B500") ' works with column B" line. Then fails.Thank you for any help.
Option Explicit
Dim fullPath As String
Private Sub FileOpenDialogBox()
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1
.Show
fullPath = .SelectedItems.Item(1) 'Set file paths for the SN report and the current Yearbook version
End With
End Sub
Private Sub GetSNReport() ' Open The SN ID Report and Copy Column A then close the report
Dim erow
FileOpenDialogBox
Do While Len(fullPath) > 0
If fullPath = "Weekly comparison.xlsm" Then
Exit Sub
End If
'Open file once found
Workbooks.Open (fullPath)
Sheets("Page 1").Select
Range("A3:A501").Copy
ActiveWorkbook.Save
ActiveWorkbook.Close
'Workbooks("Weekly comparison.xlsm").Activate
'Worksheets("Sheet1").Activate
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("B2:B500") ' works with column B
fullPath = fullPath
Loop
fullPath = fullPath
MsgBox ("GetSNReport complete")
End Sub