+ Reply to Thread
Results 1 to 4 of 4

If - else type mismatch

  1. #1
    Registered User
    Join Date
    05-14-2008
    Posts
    56

    If - else type mismatch

    Hello and thanks in advance for reading.

    In my macro, I scan some cells and process some info accordingly. I am trying to input this condition, if the offset of the cell is a certain string, then do something, else do nothing, as seen from below:

    Please Login or Register  to view this content.
    The problem is, i keep getting a Type Mismatch error. May I know how can I fix this? Thanks a lot!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello michaelkwc,

    The problem is the way you are using the Or comparator. In VBA it requires the arguments on both sides to return a boolean true or false condition. You can easily fix this by using a Select Case statement instead.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 07-28-2008 at 03:10 AM.

  3. #3
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Just to expand on what Leith said, you would need to re-write your If statement as:

    Please Login or Register  to view this content.
    The Select Case End structure makes it much easier to read.

    Richard

  4. #4
    Registered User
    Join Date
    05-14-2008
    Posts
    56
    I'll use the Select Case way then, didnt know i could use it in that manner too. thanks a lot for your help, appreciate it!

+ 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