+ Reply to Thread
Results 1 to 5 of 5

Mismatch Debbuging

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2008
    Location
    Barrie, ON, CA
    Posts
    47

    Mismatch Debbuging

    Hello,

    Below there is code for some inputboxs as well as some if statements on their results. The Exit sub situations work fine but If i do actually put a valid answer in the secod input box then it results in a mismatch error on the OR statement... Can anyone tell me why the first inputbox works fine but the second one gives me a type mismatch error when a valid input is given? Also if there's a more efficient way to do this please feel free to correct the code.

    Thanks

     Dim Month As String
      Dim Last As String
      Dim Added As String
      Answer = Application.InputBox(prompt:="Enter the name of the previous Month: I.E. July ", Type:=2)
      If Answer = "" Or Answer = False Then Ans = MsgBox("Last Month's Schedule Required", vbOK)
      If Ans = vbOK Then Exit Sub
      Last = Mid(Answer, 1, 3)
      Month = Application.InputBox(prompt:="Enter The Month to Reconcile: Exactly as shown in JDE Download/Explanation Alpha Name", Type:=2)
      If Month = "" Or Month = False Then Ans = MsgBox("Current Month's Information Required", vbOK)
      If Ans = vbOK Then Exit Sub
    Last edited by RBI; 10-09-2008 at 06:37 PM. Reason: Marked Solved

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    Declaring Month as a Variant should fix it.

    The first Inputbox works because variable Answer is undeclared so defaults to the Variant type, which can hold string, integer, boolean, single etc.

  3. #3
    Registered User
    Join Date
    09-13-2008
    Location
    Barrie, ON, CA
    Posts
    47

    thanks you

    Thanks I get it now!

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    If Month="" or Month ="False"...
    is another way to deal with that.
    Since Month is a VB function, I'd steer away from using it as the name of a variable.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    09-13-2008
    Location
    Barrie, ON, CA
    Posts
    47

    really?

    Really ?

    Ya im new to VBA so im basically learning as I go... Thanks for your imput the more info the better

+ 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. Type Mismatch error 13
    By additude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2008, 08:08 AM
  2. Mismatch error
    By danielhliu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2008, 03:17 PM
  3. run-time error 13 type mismatch (urgent)
    By godster84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-27-2007, 06:48 AM
  4. VBA Type Mismatch Error
    By ecurns in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2007, 04:24 PM
  5. Type Mismatch Errors...
    By yellephant in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2007, 09:32 AM

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