PC Review


Reply
Thread Tools Rate Thread

Copy Auto-filtered data to new sheets

 
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      1st Jul 2007
Am having trouble with following macros on line 51 (and likely beyond..). Can
someone assist? Getting R/T 424 Obj required error

Thank in advance,,

Sub AFDataToNewSheets()
Dim ws As Worksheet
Dim i As Integer
Dim curWks As Worksheet
Dim MyCell As Range
Dim NumRqdSheets As Integer
Dim RngF As Range
Dim ExistingFilterRng As Range
Dim FilterColumnWithState As Long

Application.DisplayAlerts = False ' Delete all existing sheets, except
Sheet1
For Each ws In Worksheets
If ws.Index > 1 Then
ws.Delete
End If
Next ws
Application.DisplayAlerts = True
Set curWks = Worksheets("sheet1")
FilterColumnWithState = 5 'column in the autofiltered data

With curWks
If .AutoFilterMode = False Then
MsgBox "Please apply Data|Filter|Autofilter"
Exit Sub
End If

Set ExistingFilterRng = .AutoFilter.Range

With ExistingFilterRng
.Columns(FilterColumnWithState).AdvancedFilter _
Action:=xlFilterInPlace, Unique:=True
Set RngF = Nothing
On Error GoTo 0
Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
.Resize(.Rows.Count - 1).Cells _
.SpecialCells(xlCellTypeVisible)
NumRqdSheets = RngF.Rows.Count
On Error GoTo 0
End With

If RngF Is Nothing Then
'shouldn't happen
MsgBox "something bad happened"
Exit Sub
End If

For Each MyCell In RngF.Cells
With Worksheets
.Add(after:=.Item(.Count)).Name = MyCell.Text
End With
' ** Bomb Taking place on Next line **
ExistingFilterRng.Columns(FilterColumnWithState) _
.AutoFilter Field:=1, Criteria1:=MyCell.Value _
.SpecialCells(xlCellTypeVisible).Copy
.Paste Destination:=Range("A1")
Next MyCell
.AutoFilterMode = False

ExistingFilterRng.AutoFilter
End With
Sheets("Sheet1").Activate
End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      1st Jul 2007
This worked for me. I am not sure it is exactly what you are trying to do:

Sub AFDataToNewSheets()
Dim ws As Worksheet
Dim i As Integer
Dim curWks As Worksheet
Dim MyCell As Range
Dim NumRqdSheets As Integer
Dim RngF As Range
Dim ExistingFilterRng As Range
Dim FilterColumnWithState As Long

Application.DisplayAlerts = False ' Delete all existing sheets, except
Sheet1
For Each ws In Worksheets
If ws.Index > 1 Then
ws.Delete
End If
Next ws
Application.DisplayAlerts = True
Set curWks = Worksheets("sheet1")
FilterColumnWithState = 5 'column in the autofiltered data

With curWks
If .AutoFilterMode = False Then
MsgBox "Please apply Data|Filter|Autofilter"
Exit Sub
End If

Set ExistingFilterRng = .AutoFilter.Range

With ExistingFilterRng
.Columns(FilterColumnWithState).AdvancedFilter _
Action:=xlFilterInPlace, Unique:=True
Set RngF = Nothing
On Error GoTo 0
Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
.Resize(.Rows.Count - 1).Cells _
.SpecialCells(xlCellTypeVisible)
NumRqdSheets = RngF.Rows.Count
On Error GoTo 0
End With
If RngF Is Nothing Then
'shouldn't happen
MsgBox "something bad happened"
Exit Sub
End If

For Each MyCell In RngF.Cells
If .FilterMode Then
.ShowAllData
End If
With Worksheets
Set sh = .Add(after:=.Item(.Count))
sh.Name = MyCell.Text
End With
' ** Bomb Taking place on Next line **
With ExistingFilterRng
.AutoFilter Field:=FilterColumnWithState, _
Criteria1:=MyCell.Value
.Parent.AutoFilter.Range.Copy
sh.Paste Destination:=Range("A1")
End With
Next MyCell

End With
Sheets("Sheet1").Activate
End Sub

--
Regards,
Tom Ogilvy


"JMay" wrote:

> Am having trouble with following macros on line 51 (and likely beyond..). Can
> someone assist? Getting R/T 424 Obj required error
>
> Thank in advance,,
>
> Sub AFDataToNewSheets()
> Dim ws As Worksheet
> Dim i As Integer
> Dim curWks As Worksheet
> Dim MyCell As Range
> Dim NumRqdSheets As Integer
> Dim RngF As Range
> Dim ExistingFilterRng As Range
> Dim FilterColumnWithState As Long
>
> Application.DisplayAlerts = False ' Delete all existing sheets, except
> Sheet1
> For Each ws In Worksheets
> If ws.Index > 1 Then
> ws.Delete
> End If
> Next ws
> Application.DisplayAlerts = True
> Set curWks = Worksheets("sheet1")
> FilterColumnWithState = 5 'column in the autofiltered data
>
> With curWks
> If .AutoFilterMode = False Then
> MsgBox "Please apply Data|Filter|Autofilter"
> Exit Sub
> End If
>
> Set ExistingFilterRng = .AutoFilter.Range
>
> With ExistingFilterRng
> .Columns(FilterColumnWithState).AdvancedFilter _
> Action:=xlFilterInPlace, Unique:=True
> Set RngF = Nothing
> On Error GoTo 0
> Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> .Resize(.Rows.Count - 1).Cells _
> .SpecialCells(xlCellTypeVisible)
> NumRqdSheets = RngF.Rows.Count
> On Error GoTo 0
> End With
>
> If RngF Is Nothing Then
> 'shouldn't happen
> MsgBox "something bad happened"
> Exit Sub
> End If
>
> For Each MyCell In RngF.Cells
> With Worksheets
> .Add(after:=.Item(.Count)).Name = MyCell.Text
> End With
> ' ** Bomb Taking place on Next line **
> ExistingFilterRng.Columns(FilterColumnWithState) _
> .AutoFilter Field:=1, Criteria1:=MyCell.Value _
> .SpecialCells(xlCellTypeVisible).Copy
> .Paste Destination:=Range("A1")
> Next MyCell
> .AutoFilterMode = False
>
> ExistingFilterRng.AutoFilter
> End With
> Sheets("Sheet1").Activate
> End Sub
>

 
Reply With Quote
 
=?Utf-8?B?cDQ1Y2Fs?=
Guest
Posts: n/a
 
      1st Jul 2007
Was this line:

' ** Bomb Taking place on Next line **
ExistingFilterRng.Columns(FilterColumnWithState) _
..AutoFilter Field:=1, Criteria1:=MyCell.Value _
..SpecialCells(xlCellTypeVisible).Copy
..Paste Destination:=Range("A1")

a tad long (with a line continuation line too many?) and maybe should be
something like:

ExistingFilterRng.Columns(FilterColumnWithState).AutoFilter Field:=1,
Criteria1:=MyCell.Value
ExistingFilterRng.SpecialCells(xlCellTypeVisible).Copy
.Paste Destination:=Range("A1")


depending on what you're trying to achieve.
--
p45cal


"JMay" wrote:

> Am having trouble with following macros on line 51 (and likely beyond..). Can
> someone assist? Getting R/T 424 Obj required error
>
> Thank in advance,,

[snip]
 
Reply With Quote
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      2nd Jul 2007
Thanks guys, I got it!!

"p45cal" wrote:

> Was this line:
>
> ' ** Bomb Taking place on Next line **
> ExistingFilterRng.Columns(FilterColumnWithState) _
> .AutoFilter Field:=1, Criteria1:=MyCell.Value _
> .SpecialCells(xlCellTypeVisible).Copy
> .Paste Destination:=Range("A1")
>
> a tad long (with a line continuation line too many?) and maybe should be
> something like:
>
> ExistingFilterRng.Columns(FilterColumnWithState).AutoFilter Field:=1,
> Criteria1:=MyCell.Value
> ExistingFilterRng.SpecialCells(xlCellTypeVisible).Copy
> .Paste Destination:=Range("A1")
>
>
> depending on what you're trying to achieve.
> --
> p45cal
>
>
> "JMay" wrote:
>
> > Am having trouble with following macros on line 51 (and likely beyond..). Can
> > someone assist? Getting R/T 424 Obj required error
> >
> > Thank in advance,,

> [snip]

 
Reply With Quote
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      2nd Jul 2007
Tom: What is this line doing (near end)..

..Parent.AutoFilter.Range.Copy

can't find answer googling
TIA,
Jim


"Tom Ogilvy" wrote:

> This worked for me. I am not sure it is exactly what you are trying to do:
>
> Sub AFDataToNewSheets()
> Dim ws As Worksheet
> Dim i As Integer
> Dim curWks As Worksheet
> Dim MyCell As Range
> Dim NumRqdSheets As Integer
> Dim RngF As Range
> Dim ExistingFilterRng As Range
> Dim FilterColumnWithState As Long
>
> Application.DisplayAlerts = False ' Delete all existing sheets, except
> Sheet1
> For Each ws In Worksheets
> If ws.Index > 1 Then
> ws.Delete
> End If
> Next ws
> Application.DisplayAlerts = True
> Set curWks = Worksheets("sheet1")
> FilterColumnWithState = 5 'column in the autofiltered data
>
> With curWks
> If .AutoFilterMode = False Then
> MsgBox "Please apply Data|Filter|Autofilter"
> Exit Sub
> End If
>
> Set ExistingFilterRng = .AutoFilter.Range
>
> With ExistingFilterRng
> .Columns(FilterColumnWithState).AdvancedFilter _
> Action:=xlFilterInPlace, Unique:=True
> Set RngF = Nothing
> On Error GoTo 0
> Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> .Resize(.Rows.Count - 1).Cells _
> .SpecialCells(xlCellTypeVisible)
> NumRqdSheets = RngF.Rows.Count
> On Error GoTo 0
> End With
> If RngF Is Nothing Then
> 'shouldn't happen
> MsgBox "something bad happened"
> Exit Sub
> End If
>
> For Each MyCell In RngF.Cells
> If .FilterMode Then
> .ShowAllData
> End If
> With Worksheets
> Set sh = .Add(after:=.Item(.Count))
> sh.Name = MyCell.Text
> End With
> ' ** Bomb Taking place on Next line **
> With ExistingFilterRng
> .AutoFilter Field:=FilterColumnWithState, _
> Criteria1:=MyCell.Value
> .Parent.AutoFilter.Range.Copy
> sh.Paste Destination:=Range("A1")
> End With
> Next MyCell
>
> End With
> Sheets("Sheet1").Activate
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
> "JMay" wrote:
>
> > Am having trouble with following macros on line 51 (and likely beyond..). Can
> > someone assist? Getting R/T 424 Obj required error
> >
> > Thank in advance,,
> >
> > Sub AFDataToNewSheets()
> > Dim ws As Worksheet
> > Dim i As Integer
> > Dim curWks As Worksheet
> > Dim MyCell As Range
> > Dim NumRqdSheets As Integer
> > Dim RngF As Range
> > Dim ExistingFilterRng As Range
> > Dim FilterColumnWithState As Long
> >
> > Application.DisplayAlerts = False ' Delete all existing sheets, except
> > Sheet1
> > For Each ws In Worksheets
> > If ws.Index > 1 Then
> > ws.Delete
> > End If
> > Next ws
> > Application.DisplayAlerts = True
> > Set curWks = Worksheets("sheet1")
> > FilterColumnWithState = 5 'column in the autofiltered data
> >
> > With curWks
> > If .AutoFilterMode = False Then
> > MsgBox "Please apply Data|Filter|Autofilter"
> > Exit Sub
> > End If
> >
> > Set ExistingFilterRng = .AutoFilter.Range
> >
> > With ExistingFilterRng
> > .Columns(FilterColumnWithState).AdvancedFilter _
> > Action:=xlFilterInPlace, Unique:=True
> > Set RngF = Nothing
> > On Error GoTo 0
> > Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> > .Resize(.Rows.Count - 1).Cells _
> > .SpecialCells(xlCellTypeVisible)
> > NumRqdSheets = RngF.Rows.Count
> > On Error GoTo 0
> > End With
> >
> > If RngF Is Nothing Then
> > 'shouldn't happen
> > MsgBox "something bad happened"
> > Exit Sub
> > End If
> >
> > For Each MyCell In RngF.Cells
> > With Worksheets
> > .Add(after:=.Item(.Count)).Name = MyCell.Text
> > End With
> > ' ** Bomb Taking place on Next line **
> > ExistingFilterRng.Columns(FilterColumnWithState) _
> > .AutoFilter Field:=1, Criteria1:=MyCell.Value _
> > .SpecialCells(xlCellTypeVisible).Copy
> > .Paste Destination:=Range("A1")
> > Next MyCell
> > .AutoFilterMode = False
> >
> > ExistingFilterRng.AutoFilter
> > End With
> > Sheets("Sheet1").Activate
> > End Sub
> >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      2nd Jul 2007
Your code looks like this:

> With ExistingFilterRng
> .AutoFilter Field:=FilterColumnWithState, _
> Criteria1:=MyCell.Value
> .Parent.AutoFilter.Range.Copy


which is essentially this line (for the .copy)

ExistingFilterRng.Parent.AutoFilter.Range.Copy

The parent of the range is the worksheet that owns the range. So you're copying
the autofilter range from the same worksheet that owns the existingfilterrng
(same as curwks or Sheet1 in your code).



JMay wrote:
>
> Tom: What is this line doing (near end)..
>
> .Parent.AutoFilter.Range.Copy
>
> can't find answer googling
> TIA,
> Jim
>
> "Tom Ogilvy" wrote:
>
> > This worked for me. I am not sure it is exactly what you are trying to do:
> >
> > Sub AFDataToNewSheets()
> > Dim ws As Worksheet
> > Dim i As Integer
> > Dim curWks As Worksheet
> > Dim MyCell As Range
> > Dim NumRqdSheets As Integer
> > Dim RngF As Range
> > Dim ExistingFilterRng As Range
> > Dim FilterColumnWithState As Long
> >
> > Application.DisplayAlerts = False ' Delete all existing sheets, except
> > Sheet1
> > For Each ws In Worksheets
> > If ws.Index > 1 Then
> > ws.Delete
> > End If
> > Next ws
> > Application.DisplayAlerts = True
> > Set curWks = Worksheets("sheet1")
> > FilterColumnWithState = 5 'column in the autofiltered data
> >
> > With curWks
> > If .AutoFilterMode = False Then
> > MsgBox "Please apply Data|Filter|Autofilter"
> > Exit Sub
> > End If
> >
> > Set ExistingFilterRng = .AutoFilter.Range
> >
> > With ExistingFilterRng
> > .Columns(FilterColumnWithState).AdvancedFilter _
> > Action:=xlFilterInPlace, Unique:=True
> > Set RngF = Nothing
> > On Error GoTo 0
> > Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> > .Resize(.Rows.Count - 1).Cells _
> > .SpecialCells(xlCellTypeVisible)
> > NumRqdSheets = RngF.Rows.Count
> > On Error GoTo 0
> > End With
> > If RngF Is Nothing Then
> > 'shouldn't happen
> > MsgBox "something bad happened"
> > Exit Sub
> > End If
> >
> > For Each MyCell In RngF.Cells
> > If .FilterMode Then
> > .ShowAllData
> > End If
> > With Worksheets
> > Set sh = .Add(after:=.Item(.Count))
> > sh.Name = MyCell.Text
> > End With
> > ' ** Bomb Taking place on Next line **
> > With ExistingFilterRng
> > .AutoFilter Field:=FilterColumnWithState, _
> > Criteria1:=MyCell.Value
> > .Parent.AutoFilter.Range.Copy
> > sh.Paste Destination:=Range("A1")
> > End With
> > Next MyCell
> >
> > End With
> > Sheets("Sheet1").Activate
> > End Sub
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "JMay" wrote:
> >
> > > Am having trouble with following macros on line 51 (and likely beyond..). Can
> > > someone assist? Getting R/T 424 Obj required error
> > >
> > > Thank in advance,,
> > >
> > > Sub AFDataToNewSheets()
> > > Dim ws As Worksheet
> > > Dim i As Integer
> > > Dim curWks As Worksheet
> > > Dim MyCell As Range
> > > Dim NumRqdSheets As Integer
> > > Dim RngF As Range
> > > Dim ExistingFilterRng As Range
> > > Dim FilterColumnWithState As Long
> > >
> > > Application.DisplayAlerts = False ' Delete all existing sheets, except
> > > Sheet1
> > > For Each ws In Worksheets
> > > If ws.Index > 1 Then
> > > ws.Delete
> > > End If
> > > Next ws
> > > Application.DisplayAlerts = True
> > > Set curWks = Worksheets("sheet1")
> > > FilterColumnWithState = 5 'column in the autofiltered data
> > >
> > > With curWks
> > > If .AutoFilterMode = False Then
> > > MsgBox "Please apply Data|Filter|Autofilter"
> > > Exit Sub
> > > End If
> > >
> > > Set ExistingFilterRng = .AutoFilter.Range
> > >
> > > With ExistingFilterRng
> > > .Columns(FilterColumnWithState).AdvancedFilter _
> > > Action:=xlFilterInPlace, Unique:=True
> > > Set RngF = Nothing
> > > On Error GoTo 0
> > > Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> > > .Resize(.Rows.Count - 1).Cells _
> > > .SpecialCells(xlCellTypeVisible)
> > > NumRqdSheets = RngF.Rows.Count
> > > On Error GoTo 0
> > > End With
> > >
> > > If RngF Is Nothing Then
> > > 'shouldn't happen
> > > MsgBox "something bad happened"
> > > Exit Sub
> > > End If
> > >
> > > For Each MyCell In RngF.Cells
> > > With Worksheets
> > > .Add(after:=.Item(.Count)).Name = MyCell.Text
> > > End With
> > > ' ** Bomb Taking place on Next line **
> > > ExistingFilterRng.Columns(FilterColumnWithState) _
> > > .AutoFilter Field:=1, Criteria1:=MyCell.Value _
> > > .SpecialCells(xlCellTypeVisible).Copy
> > > .Paste Destination:=Range("A1")
> > > Next MyCell
> > > .AutoFilterMode = False
> > >
> > > ExistingFilterRng.AutoFilter
> > > End With
> > > Sheets("Sheet1").Activate
> > > End Sub
> > >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?Sk1heQ==?=
Guest
Posts: n/a
 
      2nd Jul 2007
I was thinking it was something like you said..
BUT YOU NAILED IT !!
Tks Dave
Jim

"Dave Peterson" wrote:

> Your code looks like this:
>
> > With ExistingFilterRng
> > .AutoFilter Field:=FilterColumnWithState, _
> > Criteria1:=MyCell.Value
> > .Parent.AutoFilter.Range.Copy

>
> which is essentially this line (for the .copy)
>
> ExistingFilterRng.Parent.AutoFilter.Range.Copy
>
> The parent of the range is the worksheet that owns the range. So you're copying
> the autofilter range from the same worksheet that owns the existingfilterrng
> (same as curwks or Sheet1 in your code).
>
>
>
> JMay wrote:
> >
> > Tom: What is this line doing (near end)..
> >
> > .Parent.AutoFilter.Range.Copy
> >
> > can't find answer googling
> > TIA,
> > Jim
> >
> > "Tom Ogilvy" wrote:
> >
> > > This worked for me. I am not sure it is exactly what you are trying to do:
> > >
> > > Sub AFDataToNewSheets()
> > > Dim ws As Worksheet
> > > Dim i As Integer
> > > Dim curWks As Worksheet
> > > Dim MyCell As Range
> > > Dim NumRqdSheets As Integer
> > > Dim RngF As Range
> > > Dim ExistingFilterRng As Range
> > > Dim FilterColumnWithState As Long
> > >
> > > Application.DisplayAlerts = False ' Delete all existing sheets, except
> > > Sheet1
> > > For Each ws In Worksheets
> > > If ws.Index > 1 Then
> > > ws.Delete
> > > End If
> > > Next ws
> > > Application.DisplayAlerts = True
> > > Set curWks = Worksheets("sheet1")
> > > FilterColumnWithState = 5 'column in the autofiltered data
> > >
> > > With curWks
> > > If .AutoFilterMode = False Then
> > > MsgBox "Please apply Data|Filter|Autofilter"
> > > Exit Sub
> > > End If
> > >
> > > Set ExistingFilterRng = .AutoFilter.Range
> > >
> > > With ExistingFilterRng
> > > .Columns(FilterColumnWithState).AdvancedFilter _
> > > Action:=xlFilterInPlace, Unique:=True
> > > Set RngF = Nothing
> > > On Error GoTo 0
> > > Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> > > .Resize(.Rows.Count - 1).Cells _
> > > .SpecialCells(xlCellTypeVisible)
> > > NumRqdSheets = RngF.Rows.Count
> > > On Error GoTo 0
> > > End With
> > > If RngF Is Nothing Then
> > > 'shouldn't happen
> > > MsgBox "something bad happened"
> > > Exit Sub
> > > End If
> > >
> > > For Each MyCell In RngF.Cells
> > > If .FilterMode Then
> > > .ShowAllData
> > > End If
> > > With Worksheets
> > > Set sh = .Add(after:=.Item(.Count))
> > > sh.Name = MyCell.Text
> > > End With
> > > ' ** Bomb Taking place on Next line **
> > > With ExistingFilterRng
> > > .AutoFilter Field:=FilterColumnWithState, _
> > > Criteria1:=MyCell.Value
> > > .Parent.AutoFilter.Range.Copy
> > > sh.Paste Destination:=Range("A1")
> > > End With
> > > Next MyCell
> > >
> > > End With
> > > Sheets("Sheet1").Activate
> > > End Sub
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "JMay" wrote:
> > >
> > > > Am having trouble with following macros on line 51 (and likely beyond..). Can
> > > > someone assist? Getting R/T 424 Obj required error
> > > >
> > > > Thank in advance,,
> > > >
> > > > Sub AFDataToNewSheets()
> > > > Dim ws As Worksheet
> > > > Dim i As Integer
> > > > Dim curWks As Worksheet
> > > > Dim MyCell As Range
> > > > Dim NumRqdSheets As Integer
> > > > Dim RngF As Range
> > > > Dim ExistingFilterRng As Range
> > > > Dim FilterColumnWithState As Long
> > > >
> > > > Application.DisplayAlerts = False ' Delete all existing sheets, except
> > > > Sheet1
> > > > For Each ws In Worksheets
> > > > If ws.Index > 1 Then
> > > > ws.Delete
> > > > End If
> > > > Next ws
> > > > Application.DisplayAlerts = True
> > > > Set curWks = Worksheets("sheet1")
> > > > FilterColumnWithState = 5 'column in the autofiltered data
> > > >
> > > > With curWks
> > > > If .AutoFilterMode = False Then
> > > > MsgBox "Please apply Data|Filter|Autofilter"
> > > > Exit Sub
> > > > End If
> > > >
> > > > Set ExistingFilterRng = .AutoFilter.Range
> > > >
> > > > With ExistingFilterRng
> > > > .Columns(FilterColumnWithState).AdvancedFilter _
> > > > Action:=xlFilterInPlace, Unique:=True
> > > > Set RngF = Nothing
> > > > On Error GoTo 0
> > > > Set RngF = .Columns(FilterColumnWithState).Offset(1, 0) _
> > > > .Resize(.Rows.Count - 1).Cells _
> > > > .SpecialCells(xlCellTypeVisible)
> > > > NumRqdSheets = RngF.Rows.Count
> > > > On Error GoTo 0
> > > > End With
> > > >
> > > > If RngF Is Nothing Then
> > > > 'shouldn't happen
> > > > MsgBox "something bad happened"
> > > > Exit Sub
> > > > End If
> > > >
> > > > For Each MyCell In RngF.Cells
> > > > With Worksheets
> > > > .Add(after:=.Item(.Count)).Name = MyCell.Text
> > > > End With
> > > > ' ** Bomb Taking place on Next line **
> > > > ExistingFilterRng.Columns(FilterColumnWithState) _
> > > > .AutoFilter Field:=1, Criteria1:=MyCell.Value _
> > > > .SpecialCells(xlCellTypeVisible).Copy
> > > > .Paste Destination:=Range("A1")
> > > > Next MyCell
> > > > .AutoFilterMode = False
> > > >
> > > > ExistingFilterRng.AutoFilter
> > > > End With
> > > > Sheets("Sheet1").Activate
> > > > End Sub
> > > >

>
> --
>
> Dave Peterson
>

 
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
Auto copy data rows between sheets depending on date entry Struggling in Sheffield Microsoft Excel New Users 4 27th Sep 2009 01:36 PM
AUTO FILTER WITH VALUE IN CELLS AND COPY FILTERED DATA TO NEW FILE Eddy Stan Microsoft Excel Programming 3 23rd Jun 2008 02:15 PM
Subtotalling Filtered Data Across Sheets RJB Microsoft Excel Misc 3 6th Dec 2007 12:37 AM
Copy and paste data from Auto Filter / Subtotal (or apply a formula to filtered data) Harry Flashman Microsoft Excel Discussion 7 9th Oct 2007 04:39 PM
Copy auto filtered data edinclimb Microsoft Excel Misc 0 3rd Jan 2006 06:36 PM


Features
 

Advertising
 

Newsgroups
 


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