PC Review


Reply
Thread Tools Rate Thread

Copying filtered rows

 
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      8th May 2007
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 With Quote
 
 
 
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      8th May 2007
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 With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      9th May 2007
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 With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      9th May 2007
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

 
Reply With Quote
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      9th May 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying into Filtered rows Snara Microsoft Excel Discussion 3 15th May 2009 03:33 PM
Copying the filtered data to clipboard is copying non-visible rows =?Utf-8?B?U2VldGhhUmFtYW4=?= Microsoft Excel Crashes 10 12th Jul 2006 09:39 PM
Re: Copying JUST the filtered rows David Biddulph Microsoft Excel Misc 0 21st Jul 2004 06:11 PM
Re: Copying JUST the filtered rows Don Guillett Microsoft Excel Misc 0 21st Jul 2004 05:53 PM
Re: Copying JUST the filtered rows Bernie Deitrick Microsoft Excel Misc 0 21st Jul 2004 05:50 PM


Features
 

Advertising
 

Newsgroups
 


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