+ Reply to Thread
Results 1 to 4 of 4

Validate info in specific cell via Macro

  1. #1
    Registered User
    Join Date
    12-18-2014
    Location
    nyc
    MS-Off Ver
    2013
    Posts
    30

    Validate info in specific cell via Macro

    Hi- I searched the forums for this information, but couldn't find my answer. some were close, but not really what i needed. If there is a thread to answer my question, please reply with it. If not:

    In cell A1, B1 and C1 I have 3 data validation lists. A1 being Month (displayed as Month name rather than number e.g. "Jan", "Feb", "March", etc). B1 being the day #, and C1 being the year.

    In cell D1 I have the following formula, which takes the entry from those cells and puts it in mm/dd/yyyy format:
    =(MONTH(DATEVALUE(A1&" 1")))&"/"&B1&"/"&C1

    In cell E1, thanks to users on this forum, I have the following formula which validates the date to make sure its a real date, and if not the formula says "Invalid date":
    =IFERROR(DATEVALUE(D1),"Invalid date")


    At the bottom of the sheet, I've created a macro button that will prompt the user for more information. However, before it prompts the user for more information i need the macro to validate the date entered above.

    If the user entered an invalid date, i need the macro to prompt the user to fix the date and then exit the macro.
    If the user entered a valid date, i need to macro to go to next.

    Am i making this too complicated? If you have any better ideas please share, i'd be interested to see your logic.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Validate info in specific cell via Macro

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,572

    Re: Validate info in specific cell via Macro

    If Range("E1").Value = "Invalid date" Then Exit Sub
    Ben Van Johnson

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Validate info in specific cell via Macro

    Given that column A and B works, you can add "custom" data validation to column C with this formula (for C1 in this example):
    Please Login or Register  to view this content.
    That would always give you the correct dates for each month and year that you have typed in. If you type in a number that is outside the given month, the value turns up not valid and the user will have to put in another value. Create the custom validation in C1 for instance, then copy down.

    Maybe that can be of help.

    Regards,
    berlan
    Last edited by berlan; 12-20-2014 at 07:44 PM.

+ 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. VBA to validate User Form and Place info in specific cell
    By omartin616 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2013, 10:30 AM
  2. [SOLVED] Macro to copy and paste info into specific cell
    By janeml in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-28-2013, 03:38 PM
  3. [SOLVED] Sumproduct + validate dates + color cell if older as specific date.
    By dutchdog in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-05-2012, 10:51 AM
  4. A macro to validate a text entry or a specific number of digits in a cell
    By Johnny Quest in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2012, 03:28 PM
  5. Macro to relocate specific info
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2011, 10:37 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