B
BlueWolverine
Hello,
MS EXCEL 2003 on XP PRO.
I have a macro (VBA handwritten) that is supposed to cycle through my tabs
and apply an auto filter, copy and past the rows with an X in column I, and
then paste those rows into another tab. It handles this very well if a tab
has any X's, but if the filter returns zero ROWS, it copies the entire
unfiltered data set to the results tab and hides them.
Here's the code I've got. The code snippet with >> in front of it is where
the error begins to occur.
Sub Acquisition(tabname As String)
Sheets(tabname).Select
Rows("5:5").Select
Selection.AutoFilter
Range("I5").Select
ActiveCell.Offset(1, 0).Select
Row1 = ActiveCell.Row
lcv = 0
While ActiveCell.Offset(lcv, 0).Value <> ""
lcv = lcv + 1
Wend
Row2 = ActiveCell.Offset(lcv, 0).Row
Rows(Row1 & ":" & Row2).Select
Selection.Copy
'Move to results and find first blank row
Sheets("Results").Select
Range("A1").Offset(1, 0).Select
lcv = 0
While ActiveCell.Offset(lcv, 0).Value <> ""
lcv = lcv + 1
Wend
ActiveCell.Offset(lcv, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Row3 = ActiveCell.Row
lcv = 0
While ActiveCell.Offset(lcv, 0).Value <> ""
lcv = lcv + 1
Wend
Range("N" & Row3 & ":N" & lcv + 1).Value = tabname
Sheets(tabname).Select
Rows("5:5").Select
Selection.AutoFilter
Thanks.
MS EXCEL 2003 on XP PRO.
I have a macro (VBA handwritten) that is supposed to cycle through my tabs
and apply an auto filter, copy and past the rows with an X in column I, and
then paste those rows into another tab. It handles this very well if a tab
has any X's, but if the filter returns zero ROWS, it copies the entire
unfiltered data set to the results tab and hides them.
Here's the code I've got. The code snippet with >> in front of it is where
the error begins to occur.
Sub Acquisition(tabname As String)
Sheets(tabname).Select
Rows("5:5").Select
Selection.AutoFilter
Range("I5").Select
ActiveCell.Offset(1, 0).Select
Row1 = ActiveCell.Row
lcv = 0
While ActiveCell.Offset(lcv, 0).Value <> ""
lcv = lcv + 1
Wend
Row2 = ActiveCell.Offset(lcv, 0).Row
Rows(Row1 & ":" & Row2).Select
Selection.Copy
'Move to results and find first blank row
Sheets("Results").Select
Range("A1").Offset(1, 0).Select
lcv = 0
While ActiveCell.Offset(lcv, 0).Value <> ""
lcv = lcv + 1
Wend
ActiveCell.Offset(lcv, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Row3 = ActiveCell.Row
lcv = 0
While ActiveCell.Offset(lcv, 0).Value <> ""
lcv = lcv + 1
Wend
Range("N" & Row3 & ":N" & lcv + 1).Value = tabname
Sheets(tabname).Select
Rows("5:5").Select
Selection.AutoFilter
Thanks.