Consulting

Results 1 to 5 of 5

Thread: Type Mismatch

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Posts
    95
    Location

    Type Mismatch

    Hello,

    I am trying to look for specific conditions and if those conditions are met I want the selection to move down one row and check for those conditions again and so on. The code I have for this portion is giving me an error that says "Run-Time Error 13 Type Mismatch", I think it may have to do with the "=Today()" portion of it but I am not sure. Can anyone advise? Thank you much!

    If ActiveCell.Offset(0, 0).Range("A1") <> "Meeting" And ActiveCell.Offset(0, 10).Range("A1") <> "" Or ActiveCell.Offset(0, 0).Range("A1") = "Meeting" And ActiveCell.Offset(0, 10).Range("A1") <> "" And ActiveCell.Offset(0, 1).Range("A1") >= "=TODAY()" - 1 Then
    activecell.offset(1,0).range("A1").Select

  2. #2
    I think like so:
        If CStr(ActiveCell.Value) <> "Meeting" And CStr(ActiveCell.Offset(0, 10).Value) <> "" Or _
           CStr(ActiveCell.Value) = "Meeting" And CStr(ActiveCell.Offset(0, 10).Value) <> "" And CStr(ActiveCell.Offset(0, 1).Value) >= (Date - 1) Then
            ActiveCell.Offset(1, 0).Select
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Posts
    95
    Location
    Sorry it took me a couple of days to reply, been working on other things but that worked perfectly, thank you! Would you please tell me what "CStr" is and what it is used for? I have seen this before but don't know how to use it. Thank you so much for your help.

  4. #4
    VBAX Regular
    Joined
    Dec 2018
    Posts
    23
    Location
    Quote Originally Posted by infinity View Post
    Sorry it took me a couple of days to reply, been working on other things but that worked perfectly, thank you! Would you please tell me what "CStr" is and what it is used for? I have seen this before but don't know how to use it. Thank you so much for your help.
    Cstr() converts a non-string to a string. For example, Cstr(27) converts that number to "27" .

  5. #5
    Apparently, some of your cells contain errors, like #n/a. VBA tries to compare those with your texts and fails because the cell has an error. Cstr first converts the content of the cell to text before comparing it work other text and this avoids the error.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •