+ Reply to Thread
Results 1 to 8 of 8

Is it possible to use a variable to store a list of OR values?

  1. #1
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Is it possible to use a variable to store a list of OR values?

    For example suppose I want the variable columns hold the values "10 OR 15 OR 18" then simplify this by saying:

    Please Login or Register  to view this content.

    So I am testing a If the current cell is blank AND the column number is either 10, 15 or 18.

    How can this be done? In a previous post I saw something about splitting an array or a function called Split or something like that. Could that be it?
    Last edited by Excel_vba; 12-26-2013 at 10:17 PM. Reason: tags around code

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Is it possible to use a variable to store a list of OR values?

    If I get what you mean..
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Is it possible to use a variable to store a list of OR values?

    Quote Originally Posted by millz View Post
    If I get what you mean..
    Please Login or Register  to view this content.
    Yes I know about the OR function but I have another case where I need to list 1,3,6,7,8 or 9. That would get quite long and I'm trying to find a way to simply things. Is there another way?

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Is it possible to use a variable to store a list of OR values?

    You can use the Select Case statement.

    Please Login or Register  to view this content.

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

    Re: Is it possible to use a variable to store a list of OR values?

    I really can't see that working, even using Split.

    "10 OR 15 OR 18" is a string and would always be seen as TRUE in the if statement.

    If you split it, using space as a delimiter, you would end up with an array of strings - "10", "OR", "15", "OR", "18".
    If posting code please use code tags, see here.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Is it possible to use a variable to store a list of OR values?

    See
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

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

    Re: Is it possible to use a variable to store a list of OR values?

    jindon

    Won't that check if the value in Cells(currentRow, columnNo) equals 10, 15 or 18?

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Is it possible to use a variable to store a list of OR values?

    Quote Originally Posted by Excel_vba View Post
    So I am testing a If the current cell is blank AND the column number is either 10, 15 or 18.
    Ahhh...
    Please Login or Register  to view this content.

+ 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. Variable to store last row more than once.
    By bopsgtir in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2012, 04:56 PM
  2. [SOLVED] Store variable in worksheet and use that variable in VBA code
    By ExcelGal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2012, 08:20 AM
  3. Store variable values in macro code
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2011, 05:35 AM
  4. variable to store multiple values
    By somesoldiers in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2009, 08:46 AM
  5. store variable
    By keen learner in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2006, 10:30 AM

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