Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Weird ignoring of one item in a loop

Hi, I'm using Excel 2010 on Windows 7 and I have created a loop that goes through each worksheet in the workbook and performs several routine operations. For some strange reason it ignores my line about turning off the autofilter. When I run the macro it resets the cursor to A1 and eliminates any marching ants but the AutoFilter on several sheets remains 'on.' Can anyone tell me what I might be doing wrong? I've included the code below. Many thanks.

Code:
'Reset the cursor to cell A1 on all sheets, turn any autofilters off
'and lose any marching ants that might remain

    Dim i As Integer

    For i = 1 To Sheets.Count
        With Worksheets(i)
            
            Range("A1").Select
            If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
            Application.CutCopyMode = False   'This gets rid of any marching ants that may remain
           
        End With
    Next i

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Weird ignoring of one item in a loop

menken.john wrote:

Hi, I'm using Excel 2010 on Windows 7 and I have created a loop that
goes through each worksheet in the workbook and performs several routine
operations. For some strange reason it ignores my line about turning off
the autofilter. When I run the macro it resets the cursor to A1 and
eliminates any marching ants but the AutoFilter on several sheets
remains 'on.' Can anyone tell me what I might be doing wrong? I've
included the code below. Many thanks.

[snip]

Just a thought, don't check ActiveSheet.AutoFilterMode, just set it = False.

--
It's like God is pointing at me saying,
"THOU SHALT NOT GET ANY TONIGHT THOU WANTON WENCH!"
**** you, God... **** you.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Weird ignoring of one item in a loop

I agree with Auric_! You don't have to do all that checking (just slows
everything down). Just set the property to *= False*.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Weird ignoring of one item in a loop

And he don't have to select A1 on each sheet.


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Weird ignoring of one item in a loop

Thanks Auric, that worked great.
I appreciate the help.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Weird ignoring of one item in a loop

menken.john wrote:

Thanks Auric, that worked great.
I appreciate the help.


Good to hear, but see also Ron Rosenfeld's post. He caught a basic detail
that I didn't think of.

--
It's not just 3 minutes of my life,
it's *another* ****ing 3 minutes of my life!
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
dictionary-(item, item, item); Can dictionary point to an array inVBA? cate Excel Programming 1 March 6th 10 10:15 PM
Macro to loop through a list of items and print for each item JeffR Excel Programming 3 October 9th 08 10:49 AM
weird loop problem- extra rows dissapearing ker_01 Excel Programming 1 May 1st 08 05:07 PM
Ignoring Sheet in For Each Loop ExcelMonkey[_190_] Excel Programming 3 March 3rd 05 10:09 PM
Loop to Next item in For Next on Condition [email protected] Excel Programming 2 September 1st 04 08:49 PM


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