Results 1 to 5 of 5

How to check cell isnt blank upon saving or closing and color code them to show blanks

Threaded View

  1. #1
    Registered User
    Join Date
    08-22-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    8

    How to check cell isnt blank upon saving or closing and color code them to show blanks

    Could anyone expand on this a bit?
    If input is entered into column C (range C2:C100), then row cells for columns D, E ,F, H or I must NOT be blank upon save.
    Could be that one or more of these row cells are left blank by mistake.

    An error msg pops up upon attempt to save and colors each cell yellow that lacks info.

    I found this coding in another thread.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim rngCell1 As Range
    Dim rngCell2 As Range
    Dim strSheet As String
    Dim varResponse As Variant
        
        Cancel = False
        'set cells to check:
        strSheet = "Sheet1"   'name of the sheet you want to check.
        varResponse = Empty
        rngCell1 = Worksheets(strSheet).Range("A2")
        rngCell2 = Worksheets(strSheet).Range("B3")
        
        If rngCell1.Value = Empty Then
            varResponse = MsgBox("You must enter a value in cell " & rngCell1.Address, vbCritical + vbOKOnly)
            Sheets(strSheet).rngCell1.Select
        ElseIf rngCell2.Value = Empty Then
            varResponse = MsgBox("You must enter a value in cell " & rngCell2.Address, vbCritical + vbOKOnly)
            Sheets(strSheet).rngCell2.Select
        Else
            'continue code here ..
            GoTo CompleteExit
        End If
    
        Cancel = True
    
    CompleteExit:
        Cancel = False
    
    End Sub
    Last edited by Cutter; 08-29-2012 at 10:34 AM. Reason: Added code tags

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