+ Reply to Thread
Results 1 to 4 of 4

VBA For Error Message If Value is Referenced in Sheet

  1. #1
    Registered User
    Join Date
    05-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    53

    VBA For Error Message If Value is Referenced in Sheet

    Hi Everybody,

    I posted a thread on this earlier but I don't I was very clear about my problem.

    I have a worksheet called "PurchaseOrders" and a worksheet called "Orders."

    In the "Orders" Worksheet I have a command button. When this button is clicked it writes to cells in the "PurchaseOrders" Worksheet. The cell range it writes to is N21:N1000. It basically writes an invoice number which exists in cell B6 of the "Orders" Worksheet with each number listed in order.

    After it has written, when I return to the "Orders" Worksheet, if the button is clicked again but the PurchaseOrders" Worksheet N21:1000 contains an invoice, the same as "Orders" Worksheet B6 (a duplicate), I would like an error message to be returned stating "Please Create a new invoice." I already have a sub where error messages are recorded for void fields and unregistered customers.

    How would I write an if statement in this sub to say:

    IF Cell range in "PurchaseOrders" Worksheet (N21:N1000) does not equal the code in "Orders Worksheet (B6) please process code as normal. Else if it does please display an error message and do not proceed with processing any code? For some reason I'm having trouble naming the cell range.

    Any help would be greatly appreciated and thank you all for your great help with all my queries.

    Kind regards,

    Brown Teddy Bear
    Last edited by BrownTeddyBear; 06-06-2009 at 03:25 AM.

  2. #2
    Registered User
    Join Date
    05-20-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: VBA For Error Message If Value is Referenced in Sheet

    Here's an idea, In C6,

    Please Login or Register  to view this content.
    Then in your CommandButton,

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-20-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: VBA For Error Message If Value is Referenced in Sheet

    Assume Sheet1 is the Orders worksheet

  4. #4
    Registered User
    Join Date
    05-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    53

    Smile Re: VBA For Error Message If Value is Referenced in Sheet

    Hi bigmack,

    Thank you so much for your excellent solution. I've got it to work very nicely so I'm extremely grateful.

    I worked around the code and took out this part:

    Please Login or Register  to view this content.
    i didn't need it because I had a new invoice button.

    I think this statement was the key though in C6:

    Please Login or Register  to view this content.
    So thank you so much again. It works very well and I appreciate your help.

    Kind regards,

    BTB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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