+ Reply to Thread
Results 1 to 10 of 10

VBA with Empty Cell in Error

  1. #1
    Registered User
    Join Date
    08-26-2016
    Location
    Hong Kong
    MS-Off Ver
    2007
    Posts
    6

    VBA with Empty Cell in Error

    Hi!

    I am new to VBA and tried to find the answer to my specific question here. I found a code from this forum but keep seeing error message so decided to start a new thread.

    If the cell are empty, I want a message pop up and ask user to fill before proceed and the excel should not be able to save if not filled. The code I found from the forum is below: But when I run it, I keep getting error message invalid outside procedure. Also, if I want to run the same marco from C50-55, can I set code for once or have to do it 5 times ( meaning go into each cell’s code and paste the same code)
    Thank you.

    Please Login or Register  to view this content.
    Last edited by zbor; 09-08-2016 at 05:41 AM. Reason: Code tags

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VBA with Empty Cell in Error

    Post your full code


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    08-26-2016
    Location
    Hong Kong
    MS-Off Ver
    2007
    Posts
    6

    Re: VBA with Empty Cell in Error

    Sorry, I am not sure I understand:

    The above is my full code for 1 cell only. I havent figured out how to do c50-55 yet. Thanks!

    If IsEmpty(Range("c50")) Then
    Select Case MsgBox("c50 is empty. Do you want to continue?", vbYesNo Or _
    vbQuestion Or vbDefaultButton1, "Select option")

    Case vbYes
    'This must be filled
    Case vbNo
    Exit Sub
    End Select
    End If

    Capture.JPG

  4. #4
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    Re: VBA with Empty Cell in Error

    Did you put your code in Sub ........ End Sub??? Because in pic its appearing wrong ... refer below code..

    Please Login or Register  to view this content.
    Edit: Range("C53") = Empty
    Last edited by mangesh.mehendale; 09-08-2016 at 06:29 AM. Reason: Range("C53") = Empty
    Don`t care, take care...

    Regards,
    Mangesh

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: VBA with Empty Cell in Error

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  6. #6
    Registered User
    Join Date
    08-26-2016
    Location
    Hong Kong
    MS-Off Ver
    2007
    Posts
    6

    Re: VBA with Empty Cell in Error

    Sorry! Did not know about this. I will post like below from now on. Thank you

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-26-2016
    Location
    Hong Kong
    MS-Off Ver
    2007
    Posts
    6

    Re: VBA with Empty Cell in Error

    Dear Mangesh,

    Thanks for your reply. However, if I do not want the select case message box, just that if there is empty cell, message pop up and said "Cell C51 to C55 must not empty" I tried to take out that part but error message pop up saying i need select case. Thanks!


    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    Re: VBA with Empty Cell in Error

    Ok try this....

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-26-2016
    Location
    Hong Kong
    MS-Off Ver
    2007
    Posts
    6

    Re: VBA with Empty Cell in Error

    Thank you very much Mangesh! This site is so great!

  10. #10
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    Re: VBA with Empty Cell in Error

    Just Click on "Add Reputation" to Say Thanks..

+ 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. error writing to cell if a numeric text box is empty
    By Roberta.Walker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2016, 02:34 PM
  2. Formula shows #value! error when source cell is empty
    By tstowe in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-16-2012, 10:22 AM
  3. how to generate error message for an empty cell (mandatory input cell)
    By asankar24 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-20-2012, 12:37 PM
  4. Replies: 3
    Last Post: 03-24-2011, 11:02 AM
  5. VBA error code looking for next empty cell
    By jackel007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2010, 10:39 PM
  6. error in VBA code, find next empty cell
    By janloomans in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2009, 11:48 AM
  7. Replacing #VALUE! error with an empty cell
    By Breezey in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-08-2007, 10:58 AM

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