+ Reply to Thread
Results 1 to 4 of 4

Dynamic 'If" statement

  1. #1
    Registered User
    Join Date
    08-22-2016
    Location
    Wyoming
    MS-Off Ver
    Microsoft Office 2014
    Posts
    3

    Dynamic 'If" statement

    Hello. I would consider myself intermediate at vba and almost completely self taught. Given this, I have found the answer to my question in other forums, but was not completely understanding of how to apply the solution to my specific issue.

    I am attempting to basically say If "variable" = "other variable(1 to x)" then do "thing" else do "other thing" but am having issues pointing the if statement to the dynamic variable without using infinite 'or's.

    My code is as follows:

    Please Login or Register  to view this content.
    If I can clarify anything, I would be more than happy to.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,957

    Re: Dynamic 'If" statement

    Untested but try:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-22-2016
    Location
    Wyoming
    MS-Off Ver
    Microsoft Office 2014
    Posts
    3

    Re: Dynamic 'If" statement

    Thanks Trevor, it worked perfectly. Could you maybe elaborate on the use of Option Explicit in your addition? Is it used for more than just forcing the declaration of variables?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,957

    Re: Dynamic 'If" statement

    You're welcome.


    No, that's what it's for ... to force declaration of variables.




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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: 1
    Last Post: 03-09-2016, 12:17 PM
  2. Two "IF" statement with "AND" combined to make one "IF" statement in vba?
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-12-2014, 12:17 AM
  3. [SOLVED] IF Statement Evaluates as "TRUE" but Returns "FALSE" Value (Excel 2007)
    By Simcik in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2014, 12:43 PM
  4. Replies: 12
    Last Post: 06-12-2014, 02:11 PM
  5. How to change "From" & to have a dynamic "Subject" line in Excel Mailing
    By andy_iyeng in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2012, 03:04 AM
  6. Replies: 3
    Last Post: 12-14-2006, 01:36 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