+ Reply to Thread
Results 1 to 6 of 6

Improve my code: If, or, then

  1. #1
    Registered User
    Join Date
    12-19-2005
    Posts
    9

    Improve my code: If, or, then

    Is there another way to write this? Maybe have it look at a list instead of all the "Or" lines?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Improve my code: If, or, then

    Please Login or Register  to view this content.
    for instance
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Improve my code: If, or, then

    Hi,

    The way I usually do this sort of thing is to build a check cell into Excel.
    First create a list in Excel of all those cities and name the list say 'Cities'
    Then create a cell named say 'rowsearch' which will hold the search row number that you will pass from the macro
    Alongside the search row cell add a check cell called say 'check' and enter the formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Now in your macro have the following
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    12-19-2005
    Posts
    9

    Re: Improve my code: If, or, then

    Thanks for the responses...Both would definitely simplify the code. Joseph P., would I be able to insert a cell range into the case? Instead of listing all the cities in the string?

  5. #5
    Registered User
    Join Date
    12-19-2005
    Posts
    9

    Re: Improve my code: If, or, then

    Here's and example of what I mean in my second question...

    Instead of:
    Please Login or Register  to view this content.
    Can I make my case a range in excel? something like this?
    Please Login or Register  to view this content.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Improve my code: If, or, then

    no-you would need to use a different approach for that such as the find method or the match/countif worksheetfunction methods

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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