+ Reply to Thread
Results 1 to 6 of 6

Help!! How to warn users that a cell is blank

  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Help!! How to warn users that a cell is blank

    Hi,

    I'm having a bit of trouble with writing a macro which identifies a blank cell within 3 'ranges' (C2:C4000; G2:4000; B2:B4000). I want to identfy a blank cell and for the macro to stop so that the user can make a change to the sheet, and then the macro to continue until the next blank cell within the range. But a error warning pops up (where the asterix appears in the code below) which states "Next without For". Please see code below:-


    Sub BLANKCELLSWARNING()

    Dim Target, cell As Range
    Dim C, D, E As String
    C = Range("C2:C4000")
    D = Range("G2:G4000")
    E = Range("B2:B4000")

    Set Target = Sheets("Input").Range("C,D,E")
    For Each cell In Target
    If cell.Value = "" Then
    MsgBox ("This cell is blank, fill in to continue")
    *Next
    End If
    Exit Sub

    End Sub

    I'm not sure how to fix this, so any help with this would be much appreciated!! If there are any other issues with this please let me know (I'm pretty new to this, as you can tell!!)

    Thanking you in advance,

    EM1987

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Help!! How to warn users that a cell is blank

    You don't have an end if, either put it all on one line
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    There are a few other issues as well, your definition of the range wouldn't work as you expect. you set C, D and E equal to the values of the range items as you have defined them as strings. You then assign the Range("C,D,E") which I think would just give you the entire columns. You can just do it as per the example below. I'm also not sure you want the brackets on the msgbox statement.
    That said, I'm not sure this would really work as you are wanting. I don't think you would be able to edit the cells when the message box appears. I think you would need to end the macro each time to enable the user to change the cell. Also
    Please Login or Register  to view this content.
    Might be a slightly more efficient way of executing the loop.

  3. #3
    Registered User
    Join Date
    10-04-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Help!! How to warn users that a cell is blank

    Fantastic, thanks for your help! Just one more question: is there a way to get the msgbox to appear at the end (i.e. after the checking has been done), and with the number of cells which have been changed?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Help!! How to warn users that a cell is blank

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-25-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    150

    Re: Help!! How to warn users that a cell is blank

    If you want to change the value of the cell without stopping your macro, change this line:
    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-04-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Help!! How to warn users that a cell is blank

    That's perfect! Thanks for your help Yudlugar!!

+ 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. [SOLVED] Check if cell value is on a list in another range and warn user.
    By KevBotes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 06:46 AM
  2. Warn when cells are empty
    By adgjqetuo in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-08-2009, 10:03 PM
  3. Warn about duplicate entries
    By bolao in forum Excel General
    Replies: 5
    Last Post: 11-06-2007, 06:46 PM
  4. [SOLVED] Warn if already entered
    By Pat in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2005, 10:06 AM
  5. Warn when a cell value has changed
    By LesLdh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-16-2005, 02:33 PM

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