Results 1 to 11 of 11

Using variable for Autofilter Criteria1

Threaded View

  1. #1
    Registered User
    Join Date
    08-13-2017
    Location
    India
    MS-Off Ver
    2010
    Posts
    46

    Using variable for Autofilter Criteria1

    I have the following snippet from my VBA

    Dim i As Integer
    Dim value As Integer
    
    
    For i = 1 To 52
         ActiveSheet.Range(Cells(1, 1), Cells(lRow, 11)).AutoFilter Field:=1, Criteria1:=i
       
    Next i
    
    End Function
    I know there is something wrong here

    1) If I record a macro, I get Criteria1:="1" if 1 is not filtered out, Criteria2:="2" if 2 is not filtered out and so on...

    How can I get 1 through 52 in a loop so that I can have 1,2,...52 not filtered out sequentially and do tasks I subsequently want to carry out?

    Is the above approach correct. I think its wrong because I set Criteria1:=i and i is an integer above

    Whereas, in the recorded macro, 1 or 2 or...appear in double quotes "1", or "2",....

    Can anyone help to Set Criteria1 as a variable because I want to filter out 52 times (1 first time, 2 second time, 3 third time,.....52 52nd time)

    Thanks a lot in advance
    Last edited by ateestructural; 09-17-2017 at 07:57 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [URGENT][Help with a VBA Macro - Maximum with criterias][URGENT]
    By mahmoudmerhi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2013, 03:39 PM
  2. Need urgent help with error! Urgent!
    By heidenman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2009, 04:31 AM
  3. please help! really urgent! thanks
    By starlover123 in forum Excel General
    Replies: 1
    Last Post: 07-03-2009, 07:19 PM
  4. urgent help
    By b166er in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-22-2006, 08:45 PM
  5. urgent, help!
    By eeehwc in forum Excel General
    Replies: 5
    Last Post: 11-26-2005, 01:30 PM
  6. Urgent-Urgent VBA LOOP
    By Jeff in forum Excel General
    Replies: 0
    Last Post: 10-06-2005, 01:05 PM
  7. Hi All, need urgent help please.
    By FrigidDigit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2005, 12:05 PM
  8. Please Help (Urgent)
    By jyang in forum Excel General
    Replies: 0
    Last Post: 08-07-2005, 08:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1