+ Reply to Thread
Results 1 to 8 of 8

difficulty getting variable to work in activesheet.range filter field

  1. #1
    Registered User
    Join Date
    02-20-2014
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    16

    difficulty getting variable to work in activesheet.range filter field

    I'm sure this is something simple but I can't figure it out for the life of me. I have the variable "bob" which contains custom ranges based on the file name. An example value of "bob" shows as follows:

    "-10", "-9", "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", " "

    If I hardcode the exact same information into the activesheet.range section it works exactly as it is supposed to. But if I put in the variable (when stepping through I have verified that the variable does hold the correct values) instead it simply does not work. What am I doing wrong?

    Also here is a portion of the code being used. with the location in question in bold

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: difficulty getting variable to work in activesheet.range filter field

    If you are trying to filter -10 to 0, why not use between -10 and 0 instead of specifying every number inbetween?

    By the way, Array(bob) will create an array with one item, the string '"-10", "-9", "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", " "'.

    If you wanted an array from '"-10", "-9", "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", " "' you could use Split with comma as a delimiter.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-20-2014
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: difficulty getting variable to work in activesheet.range filter field

    I was under the assumption that I could not use between because the column views all entries as text instead of numbers hence specifying each individually, was I incorrect in this assumption? As for the reasoning that makes sense now that you mention it. I will test that and see if that fixes it.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: difficulty getting variable to work in activesheet.range filter field

    Aren't you converting any number as text columns to 'real' numbers when opening the file?

  5. #5
    Registered User
    Join Date
    02-20-2014
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: difficulty getting variable to work in activesheet.range filter field

    Unfortunately the files in question have auto part numbers in them and some of the manufacturers like to use alphanumeric strings such as 300E523 which will convert to an exponent if viewed as a number. So no, not converting to real numbers. As for split I cannot seem to get it to work.

    Please Login or Register  to view this content.
    Try as I might google searches are not very helpful in this context and I am thinking I am using it incorrectly.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: difficulty getting variable to work in activesheet.range filter field

    Split returns an array, so there's no need for Array.

  7. #7
    Registered User
    Join Date
    02-20-2014
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: difficulty getting variable to work in activesheet.range filter field

    it keeps kicking back a error 13 type mismatch.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: difficulty getting variable to work in activesheet.range filter field

    Have you checked the array?

+ 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. Replies: 3
    Last Post: 03-08-2013, 09:28 AM
  2. [SOLVED] Difficulty with Row as Variable determined by value in another cell
    By Avalon143812 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2012, 02:17 PM
  3. ActiveSheet.ListObjects Variable Help
    By nickflorez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2011, 01:00 PM
  4. Difficulty charting complicated multiple-variable data.
    By steknight in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-22-2010, 04:53 AM
  5. Variable as argument in filter range
    By Bert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2005, 07:06 PM

Tags for this Thread

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