+ Reply to Thread
Results 1 to 3 of 3

If Then Type Mismatch

  1. #1
    Registered User
    Join Date
    06-19-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    30

    If Then Type Mismatch

    Hello, I am working with this section of a macro and it keeps giving me the error "Type Mismatch".

    Please Login or Register  to view this content.
    I am trying to see if the value in each of the cells in H7:H40 is less than 5 minutes. Anyone know what I'm doing wrong?

  2. #2
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: If Then Type Mismatch

    Quote Originally Posted by MeggieDoodles View Post
    Please Login or Register  to view this content.
    I am trying to see if the value in each of the cells in H7:H40 is less than 5 minutes. Anyone know what I'm doing wrong?
    I would not expect a "type mismatch" error. But "00:05:00" with quotes is not the way to write "5 minutes" in VBA. (Not even in Excel.)

    If cell.Value is numeric time, change "00:05:00" to #00:05:00#. That is, change double-quotes to hash marks. Caveat: VBA might change the appearance of the time constant.

    If that does not remedy the problem, I suggest that you attach an example Excel file. Click on Go Advanced to see the Attach File icon in the toolbar.
    Last edited by joeu2004; 12-04-2015 at 04:16 PM. Reason: cosmetic

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If Then Type Mismatch

    It all depends on the formatting. With cell formatting as h:mm:ss; this works just fine

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

+ 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. [SOLVED] type mismatch
    By umbata in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2014, 10:24 AM
  2. VBA type mismatch
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2014, 07:32 AM
  3. Run Type error 13 Type Mismatch
    By Affan Khan in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-13-2012, 12:58 PM
  4. [SOLVED] Run-type error 13 type mismatch
    By misop in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-05-2012, 04:08 AM
  5. [SOLVED] Type Mismatch: array or user defined type expected
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2006, 10:45 AM
  6. [SOLVED] Type mismatch using rnge as Range with Type 8 Input Box
    By STEVE BELL in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-03-2005, 01:10 AM
  7. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 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