+ Reply to Thread
Results 1 to 4 of 4

VBA criteria to reference cell in workbook

  1. #1
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    VBA criteria to reference cell in workbook

    Hi,

    I have the below code and I would like to have the filter that current looks for the string 'Alpha Region' to be dynamic and refer to cell B1 on the tab RegionalAnalysis. Currently it is just referring to a text string - is there anyway to make this dynamic?


    HTML Code: 
    Any help greatly appreciated

  2. #2
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,104

    Re: VBA criteria to reference cell in workbook

    Hello Tony,

    You could just change the Criteria1 as follows:-

    Firstly declare a variable such as:-

    Please Login or Register  to view this content.
    then give the variable a value:-

    Please Login or Register  to view this content.
    then filter on Crit1

    Please Login or Register  to view this content.
    You should then be able to filter on whatever value that you place in B1 (from a drop down perhaps?).

    I hope that this helps.

    Cheerio,
    vcoolio.

  3. #3
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: VBA criteria to reference cell in workbook

    Hi vcoolio,

    Thank you - for some reason I had to take the check off if there was any data displayed after Autofiltering as it was only working for some regions but not others - but I can look at that later.

    Thanks for your help!

  4. #4
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,104

    Re: VBA criteria to reference cell in workbook

    You're welcome Tony. I'm glad to have been able to assist.

    Generally, using the Autofilter within a "With" statement, should negate the need for a check. A couple of examples follow:-

    Please Login or Register  to view this content.
    ...or, if there is at least one completely empty row directly above the dataset (i.e. Row 4), then this should work as well:


    Please Login or Register  to view this content.
    Thanks for the rep!

    Cheerio,
    vcoolio.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sumifs reference criteria is text but I want to reference cell
    By bbeards2 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-06-2015, 04:04 PM
  2. Replies: 4
    Last Post: 12-01-2013, 03:22 AM
  3. Replies: 0
    Last Post: 06-01-2013, 05:04 AM
  4. [SOLVED] copy active sheet, create new workbook, name new workbook based on cell reference
    By jm0392 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2012, 07:12 PM
  5. Replies: 2
    Last Post: 05-01-2009, 07:06 PM
  6. workbook reference in cell reference: as clearly as i can be...
    By nbsorei in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-19-2008, 03:46 PM
  7. Replies: 1
    Last Post: 02-03-2006, 12:00 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