Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problems copy data when using filter in place

Hi
I'm using the advanced filter in place to filter a list based on
certain criteria and then copying the filter result into another
worksheet. It works OK if there is data matching the criteria but if
there is no matching data it copies the whole of the "list range".
Any help on how I can prevent this would be gratefully received.

'FILTERS THE IMPORTED DATA FOR THE REFERENCE NUMBERS AT EACH
DIVISION LEVEL
Criterion.Clear
FilterForLevels.FormulaR1C1 = "=LEN(R[6]C)=" & LenLevel_1 & ""


Sheets("Import Area").Select
Database.Select
Selection.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Range("A3:B4"), Unique:=False

Sheets("Level_1").Select
Range("a4:e6000").Clear

Sheets("Import Area").Select
RefNumbers.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Level_1").Select
Range("a4").Select
ActiveSheet.Paste
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Problems copy data when using filter in place

You can count the visible rows before and after the filter...
ActiveSheet.Cells.SpecialCells(xlCellTypeVisible). Rows.Count
--
Jim Cone
Portland, Oregon USA
http://www.contextures.com/excel-sort-addin.html




"Snuffwinkler"
wrote in message
...
Hi
I'm using the advanced filter in place to filter a list based on
certain criteria and then copying the filter result into another
worksheet. It works OK if there is data matching the criteria but if
there is no matching data it copies the whole of the "list range".
Any help on how I can prevent this would be gratefully received.

'FILTERS THE IMPORTED DATA FOR THE REFERENCE NUMBERS AT EACH
DIVISION LEVEL
Criterion.Clear
FilterForLevels.FormulaR1C1 = "=LEN(R[6]C)=" & LenLevel_1 & ""


Sheets("Import Area").Select
Database.Select
Selection.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Range("A3:B4"), Unique:=False

Sheets("Level_1").Select
Range("a4:e6000").Clear

Sheets("Import Area").Select
RefNumbers.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Level_1").Select
Range("a4").Select
ActiveSheet.Paste
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Problems copy data when using filter in place

I think that this will give you the number of rows visible in the first area --
not the entire range (well, if there are visible cells).



On 07/23/2010 08:17, Jim Cone wrote:
You can count the visible rows before and after the filter...
ActiveSheet.Cells.SpecialCells(xlCellTypeVisible). Rows.Count


--
Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Problems copy data when using filter in place

You could look at the number of cells visible in the first column of the
filtered range.

dim VisRows as long
with database 'your range variable???
visrows = .columns(1).cells.specialcells(xlcelltypevisible). cells.count
end with

And since your filtered range (database) includes the headers:

if visrows = 1 then
'only header
else
'do the real work
end if



On 07/23/2010 06:30, Snuffwinkler wrote:
Hi
I'm using the advanced filter in place to filter a list based on
certain criteria and then copying the filter result into another
worksheet. It works OK if there is data matching the criteria but if
there is no matching data it copies the whole of the "list range".
Any help on how I can prevent this would be gratefully received.

'FILTERS THE IMPORTED DATA FOR THE REFERENCE NUMBERS AT EACH
DIVISION LEVEL
Criterion.Clear
FilterForLevels.FormulaR1C1 = "=LEN(R[6]C)="& LenLevel_1& ""


Sheets("Import Area").Select
Database.Select
Selection.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Range("A3:B4"), Unique:=False

Sheets("Level_1").Select
Range("a4:e6000").Clear

Sheets("Import Area").Select
RefNumbers.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Level_1").Select
Range("a4").Select
ActiveSheet.Paste


--
Dave Peterson
Reply
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 each data record of a name list and place it under the onecopied andreashermle Excel Programming 2 October 7th 09 04:06 PM
Retrieve text from filter data in workbook 1 and place values in 2 RHall Excel Discussion (Misc queries) 2 January 6th 08 04:26 AM
Still having Filter/Copy problems Mark Excel Programming 4 August 6th 07 04:06 PM
Problems with same macro diferent place jose luis Excel Programming 8 May 27th 05 08:14 PM
Problems with same macro diferent place Norie Excel Programming 0 May 26th 05 09:31 PM


All times are GMT +1. The time now is 05:27 AM.

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

About Us

"It's about Microsoft Excel"