Results 1 to 11 of 11

MsgBox if any cell within range is blank

Threaded View

  1. #1
    Registered User
    Join Date
    04-18-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    4

    MsgBox if any cell within range is blank

    Hi,

    This is my first post and I'm new to VBA. I'm trying to highlight any blank cells and display a message saying "there are incomplete fields" if any cells within a range are blank. I have created a button and managed to get the code to highlight any blank cells in yellow, I'm struggling to get the message box to only appear once, the best I've managed so far is it appears as the macro checks every cell. This is my current code:
    Private Sub CommandButton1_Click()
    
    Dim myRange As Range
        Set myRange = Sheets("Model Exceptions Proforma").Range("=B5:B6,E5,H6:K16,D22:E28,J22:K28,J29,F30:K31,J35,D37:E43,J37:K43,J44,D47:E53,J47:K53,J54,D55,F58,F59,F60:K61,D62,I65:K66,D67:K70,G73:K76,D78,G77,I81:K83,D84,I87:K88,D89,I92:K93,D94,A98")
        For Each myCell In myRange
            If myCell.Text = "" And myCell.Interior.Color = vbWhite Then
                myCell.Interior.ColorIndex = 36
                MsgBox "There are incomplete fields"
            Else
                myCell.Interior.ColorIndex = xlNone
            End If
            Next
           
    End Sub
    This might confuse things further but I also have conditional formatting grey out some cells that don't require completion depending on what category is selected, I think the current code still colours those cells in yellow as they are left blank and then the conditional formatting just puts the grey over the top (so the yellow isn't visible). I would need the error message to only count blank cells that the conditional formatting doesn't grey out. Is that possible?

    Thanks in advance

    Sam

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Attached Files Attached Files
    Last edited by Samanthabenton; 04-25-2016 at 06:58 AM. Reason: solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Display msgbox once if any cell in range is a specific color
    By anthronewman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2015, 04:32 PM
  2. Replies: 3
    Last Post: 07-21-2015, 09:15 AM
  3. VBA if active cell blank than msgbox to remind
    By dekueb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2015, 10:48 AM
  4. Replies: 2
    Last Post: 11-22-2013, 01:07 PM
  5. [SOLVED] MsgBox when a cell within a range changes to a specific value
    By kitackers in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2012, 08:49 AM
  6. MsgBox if the Active Cell is not within a preferred Range
    By Winon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2011, 05:52 AM
  7. How to show MsgBox if a any cell value is > 17 in a range
    By syedalamgir in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2011, 08:48 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