Hi All,
This probably sounds a little silly, due to built in functions and security measures to stop Excel from going mad, but I have the error box (image attached) come up, and I was wondering if i could by pass it by adding some code to my existing VBA.
So my code currently finds a set of matches, and then copy and pastes them onto another sheet, then changes the criteria and repeats this. The issue is that I am about half way through the criteria and the runtime error appears. Is there a way to bypass this error, so if there is nothing to copy and paste, it moves on to the next step and tries again until the end of the code?
Extract of code:
The error appears on the line "ActiveSheet.Paste", right after "Range("A40000").Select
Many thanks in advance for your help.
This probably sounds a little silly, due to built in functions and security measures to stop Excel from going mad, but I have the error box (image attached) come up, and I was wondering if i could by pass it by adding some code to my existing VBA.
So my code currently finds a set of matches, and then copy and pastes them onto another sheet, then changes the criteria and repeats this. The issue is that I am about half way through the criteria and the runtime error appears. Is there a way to bypass this error, so if there is nothing to copy and paste, it moves on to the next step and tries again until the end of the code?
Extract of code:
VBA Code:
Sheets("Theatre Data").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveSheet.Range("$A$1:$XFC$15000").AutoFilter Field:=8
ActiveWorkbook.Worksheets("Theatre Data").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Theatre Data").AutoFilter.Sort.SortFields.Add2 Key _
:=Range("H1:H15000"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Theatre Data").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("Episode Workings").Select
ActiveSheet.Range("$A$1:$J$75000").AutoFilter Field:=1, Criteria1:="8"
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.ClearContents
ActiveSheet.Range("$A$1:$J$75000").AutoFilter Field:=1
ActiveWorkbook.Worksheets("Episode Workings").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Episode Workings").AutoFilter.Sort.SortFields.Add2 _
Key:=Range("A1:A75000"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Episode Workings").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("Theatre Data").Select
ActiveSheet.Range("$A$1:$XFC$15000").AutoFilter Field:=8, Criteria1:="Yes"
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Matched Theatre Data").Select
Range("A40000").Select
ActiveSheet.Paste
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
The error appears on the line "ActiveSheet.Paste", right after "Range("A40000").Select
Many thanks in advance for your help.