Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Error stepping through Autofiltered visible range

I'm using a macro supplied by Tom Ogilvy which works great, except for a
small error. The code steps down through the visible cells in a single
column after using the Autofilter. It's called by another macro, which
inserts a formula.

The error comes when the ActiveCell is the last cell in the filtered visible
range. When the macro tires to increment down, it errors out at the line I
have marked below. I'm wondering what I did to Tom's code when I put in my
stuff to make it give errors.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
*** If Not rng Is Nothing Then *** Debug hilites this line
rng1(1).Select
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error stepping through Autofiltered visible range

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I'm using a macro supplied by Tom Ogilvy which works great, except for a
small error. The code steps down through the visible cells in a single
column after using the Autofilter. It's called by another macro, which
inserts a formula.

The error comes when the ActiveCell is the last cell in the filtered

visible
range. When the macro tires to increment down, it errors out at the line

I
have marked below. I'm wondering what I did to Tom's code when I put in

my
stuff to make it give errors.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
*** If Not rng Is Nothing Then *** Debug hilites this line
rng1(1).Select
End If
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Error stepping through Autofiltered visible range

Thank you, Tom. That was it.

Ed

"Tom Ogilvy" wrote in message
...
Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I'm using a macro supplied by Tom Ogilvy which works great, except for a
small error. The code steps down through the visible cells in a single
column after using the Autofilter. It's called by another macro, which
inserts a formula.

The error comes when the ActiveCell is the last cell in the filtered

visible
range. When the macro tires to increment down, it errors out at the

line
I
have marked below. I'm wondering what I did to Tom's code when I put in

my
stuff to make it give errors.

Ed

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
*** If Not rng Is Nothing Then *** Debug hilites this line
rng1(1).Select
End If
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
Delete some column headings from an autofiltered range. Champ Excel Worksheet Functions 1 February 17th 10 06:39 AM
Save autofiltered visible sheet to csv file? [email protected] Excel Discussion (Misc queries) 3 February 26th 07 10:38 PM
How to plot only visible autofiltered rows in a data list Craig Charts and Charting in Excel 1 June 28th 05 08:38 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM


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