+ Reply to Thread
Results 1 to 5 of 5

Validation Error- Type Mismatch?

  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Validation Error- Type Mismatch?

    Hello all,

    I have a validation button which runs through my spreadsheet and makes sure there is data in each cell. If a cell is missing data, an error message is entered into the last row.

    Each row must be a specific type of data (ex. vendor- text, amount-currency, approval date- date) so I have defined each row as such in the class1 module (vendor as string, amount as double, approvedate as date). However, the error message is a string, so when I click the validate button, it only recognizes when data from the vendor row is missing. Any suggestions on how I can check that the data in the amount row is a currency, and the data in the approval date row is a date with my validation button?

    I have attached my spreadsheet for reference. My code for the validation button is in Module1 and Class1. Thanks in advance for the help!

    Excel Help Validate.xlsm

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Validation Error- Type Mismatch?

    How about this,

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JapanDave; 06-22-2012 at 01:04 PM.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Validation Error- Type Mismatch?

    Thanks alot!

    I adapted it a little, and ended up changing how I defined the columns in the class module to all strings, but the final outcome is just as I hoped it would be - that the validate checks if there is data in the cell, and then makes sure the data makes sense.

    I have attached my updated spreadsheet for reference.

    Excel Help Validate.xlsm

    Thank you again!

  4. #4
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Validation Error- Type Mismatch?

    Excel Help Validate.xlsm

    CORRECT FILE!! (I attached the wrong one in my last post- sorry!)

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Validation Error- Type Mismatch?

    Glad you could adapt the code to suit.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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