LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default COPY PASTE with FILTER copies anti-filtered results as hidden rows

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
Selection.AutoFilter Field:=9, Criteria1:="<"
ActiveWindow.SmallScroll Down:=-39

'Get this Range correct.

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.

--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy/paste data across filtered rows jday Excel Worksheet Functions 1 November 11th 09 05:33 PM
Copy and Paste Format in filtered rows XLFanatico Excel Discussion (Misc queries) 6 July 24th 09 05:53 PM
copy/paste with hidden rows don't want hidden parts to paste robynne Excel Discussion (Misc queries) 1 September 21st 07 09:23 PM
using macro to copy and paste filtered results, what if blank? priceyindevon Excel Worksheet Functions 2 December 14th 06 10:09 AM
How to paste data over the hidden rows in a sheet with a filter hezemeftez Excel Discussion (Misc queries) 2 August 2nd 06 03:29 PM


All times are GMT +1. The time now is 08:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"