Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Copying filtered rows

After I filter list I want to copy only the visible rows but with the below
code it copies the hidden rows.
also
Private Sub CommandButton1_Click() ' Analyze records

Dim c As Range
Dim ws As Worksheet
Dim iEnd As Long
Dim ws1 As Worksheet

UndoMyFilter

Set ws = Sheets("Summary")

iEnd = ws.Range("B7").End(xlDown).Row

For Each c In ws.Range("B7:B" & iEnd)
If c < ws.Range("G1") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B26:B" & iEnd)
If c ws.Range("G2") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B7:B" & iEnd)
If c.Offset(0, 2) < ws.Range("G3") Then c.EntireRow.Hidden = True
Next c

Application.CutCopyMode = False
Range("B6:F6").Select

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Analyze").Select
Range("E36").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Copying filtered rows

Here's a macro I use (often).


Sub DumpAutoFilterToNewSheet()
Dim ws As Worksheet ' Your Current sheet - the sheet with the Auto-Filter
Dim ws1 As Worksheet ' This will be a newly added sheet
Set ws = ActiveSheet
Set ws1 = Worksheets.Add
ws.Activate
ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(1, 1) ' Pastes into A1 - Change to suit
End Sub

"Oldjay" wrote:

After I filter list I want to copy only the visible rows but with the below
code it copies the hidden rows.
also
Private Sub CommandButton1_Click() ' Analyze records

Dim c As Range
Dim ws As Worksheet
Dim iEnd As Long
Dim ws1 As Worksheet

UndoMyFilter

Set ws = Sheets("Summary")

iEnd = ws.Range("B7").End(xlDown).Row

For Each c In ws.Range("B7:B" & iEnd)
If c < ws.Range("G1") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B26:B" & iEnd)
If c ws.Range("G2") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B7:B" & iEnd)
If c.Offset(0, 2) < ws.Range("G3") Then c.EntireRow.Hidden = True
Next c

Application.CutCopyMode = False
Range("B6:F6").Select

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Analyze").Select
Range("E36").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Copying filtered rows

When I copy
ws.Activate

ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(36, 5)
I get an error
Note
I am not auto filtering . I am just hiding rows and then trying to copy the
visible rows to another sheet

"JMay" wrote:

Here's a macro I use (often).


Sub DumpAutoFilterToNewSheet()
Dim ws As Worksheet ' Your Current sheet - the sheet with the Auto-Filter
Dim ws1 As Worksheet ' This will be a newly added sheet
Set ws = ActiveSheet
Set ws1 = Worksheets.Add
ws.Activate
ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(1, 1) ' Pastes into A1 - Change to suit
End Sub

"Oldjay" wrote:

After I filter list I want to copy only the visible rows but with the below
code it copies the hidden rows.
also
Private Sub CommandButton1_Click() ' Analyze records

Dim c As Range
Dim ws As Worksheet
Dim iEnd As Long
Dim ws1 As Worksheet

UndoMyFilter

Set ws = Sheets("Summary")

iEnd = ws.Range("B7").End(xlDown).Row

For Each c In ws.Range("B7:B" & iEnd)
If c < ws.Range("G1") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B26:B" & iEnd)
If c ws.Range("G2") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B7:B" & iEnd)
If c.Offset(0, 2) < ws.Range("G3") Then c.EntireRow.Hidden = True
Next c

Application.CutCopyMode = False
Range("B6:F6").Select

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Analyze").Select
Range("E36").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Copying filtered rows

Thanks for the help

"Oldjay" wrote:

When I copy
ws.Activate

ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(36, 5)
I get an error
Note
I am not auto filtering . I am just hiding rows and then trying to copy the
visible rows to another sheet

"JMay" wrote:

Here's a macro I use (often).


Sub DumpAutoFilterToNewSheet()
Dim ws As Worksheet ' Your Current sheet - the sheet with the Auto-Filter
Dim ws1 As Worksheet ' This will be a newly added sheet
Set ws = ActiveSheet
Set ws1 = Worksheets.Add
ws.Activate
ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(1, 1) ' Pastes into A1 - Change to suit
End Sub

"Oldjay" wrote:

After I filter list I want to copy only the visible rows but with the below
code it copies the hidden rows.
also
Private Sub CommandButton1_Click() ' Analyze records

Dim c As Range
Dim ws As Worksheet
Dim iEnd As Long
Dim ws1 As Worksheet

UndoMyFilter

Set ws = Sheets("Summary")

iEnd = ws.Range("B7").End(xlDown).Row

For Each c In ws.Range("B7:B" & iEnd)
If c < ws.Range("G1") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B26:B" & iEnd)
If c ws.Range("G2") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B7:B" & iEnd)
If c.Offset(0, 2) < ws.Range("G3") Then c.EntireRow.Hidden = True
Next c

Application.CutCopyMode = False
Range("B6:F6").Select

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Analyze").Select
Range("E36").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Copying filtered rows

Well using auto-filter would certainly be easier (on you), even if you just
created a new column (at the far right - last column) entitled Select? and
include this in the auto-filter table list - Just enter a "Y" (w/o the " "'s)
in the rows you wish to be visible and copy; then presto, and use my
suggested macro.

"Oldjay" wrote:

When I copy
ws.Activate

ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(36, 5)
I get an error
Note
I am not auto filtering . I am just hiding rows and then trying to copy the
visible rows to another sheet

"JMay" wrote:

Here's a macro I use (often).


Sub DumpAutoFilterToNewSheet()
Dim ws As Worksheet ' Your Current sheet - the sheet with the Auto-Filter
Dim ws1 As Worksheet ' This will be a newly added sheet
Set ws = ActiveSheet
Set ws1 = Worksheets.Add
ws.Activate
ws.AutoFilter.Range.Copy _
Destination:=ws1.Cells(1, 1) ' Pastes into A1 - Change to suit
End Sub

"Oldjay" wrote:

After I filter list I want to copy only the visible rows but with the below
code it copies the hidden rows.
also
Private Sub CommandButton1_Click() ' Analyze records

Dim c As Range
Dim ws As Worksheet
Dim iEnd As Long
Dim ws1 As Worksheet

UndoMyFilter

Set ws = Sheets("Summary")

iEnd = ws.Range("B7").End(xlDown).Row

For Each c In ws.Range("B7:B" & iEnd)
If c < ws.Range("G1") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B26:B" & iEnd)
If c ws.Range("G2") Then c.EntireRow.Hidden = True
Next c
For Each c In ws.Range("B7:B" & iEnd)
If c.Offset(0, 2) < ws.Range("G3") Then c.EntireRow.Hidden = True
Next c

Application.CutCopyMode = False
Range("B6:F6").Select

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Analyze").Select
Range("E36").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


End Sub



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
Copying four filtered cells CousinExcel Excel Discussion (Misc queries) 1 January 15th 10 04:14 PM
copying one column with hidden/filtered rows to another colum Rechie Excel Discussion (Misc queries) 2 September 14th 09 06:28 PM
Copying Filtered Data Shirley Munro Excel Discussion (Misc queries) 1 June 23rd 05 01:18 AM
Copying filtered data cghall55 Excel Programming 5 January 11th 05 04:14 PM
Filtered Visible Rows & VBA Non-Filtered Rows Displayed QTE[_15_] Excel Programming 8 July 11th 04 02:21 AM


All times are GMT +1. The time now is 08:23 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"