Metaripley
Board Regular
- Joined
- Dec 31, 2014
- Messages
- 93
So ive got a autofilter with a VBA code to select the filtered data and copy it somewhere else.
But once the code has run a first time the 2nd time the autofilter is run it trows an error because there is no data (run time error 1004 no cell are found).
Until here it does what its supposed to do...
So I made an On Error Goto in the hope it would skip all next steps and end the macro.
But it does skip the select autofilter step, but it will continue all next steps and doesnt skip to the end of the macro as I thought it would.
But once the code has run a first time the 2nd time the autofilter is run it trows an error because there is no data (run time error 1004 no cell are found).
Until here it does what its supposed to do...
So I made an On Error Goto in the hope it would skip all next steps and end the macro.
But it does skip the select autofilter step, but it will continue all next steps and doesnt skip to the end of the macro as I thought it would.
VBA Code:
Sub Select_fliterd()
'Select section
On Error Resume Next
ActiveSheet.Range("A2:M430").SpecialCells(xlCellTypeVisible).Select
On Error GoTo endProc
'Selection.Copy
'go to location
Sheets("Planning").Select
Range("G1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
ActiveCell.Offset(1).Select
'past values only
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
endProc:
End Sub