Excel workbook validation

Advocate005

New Member
Joined
Sep 27, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Good Day,
I am trying to get the Hang of Excel Macros and I will appreciate any help I can get.
I have an excel sheet with columns A to P and rows 1 to 90, Some of the cells are highlighted in green to signify cells that users need to fill with information. I am trying to write a Macros that will check all the cells highlighted in green within the sheet that is empty. Any cell highlighted in green that has information filled in should have the green highlight removed while any cell highlighted in green that is empty should remain highlighted in green and display a message to fill in the missing information.

I will appreciate any help or guidance I can get.

Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I wrote this macro that seems to do what you said. You have to provide the name of the worksheet where data resides and then specify first and last row and column. Column A = 1, etc. So if data is in columns A to P then first column is 1 and last column is 16. I hope this is helpful

VBA Code:
Sub ProcessAnswerCells()

    Dim iUnansweredCount As Long

    Dim iFirstCol As Long
    Dim iFirstRow As Long

    Dim iLastCol As Long
    Dim iLastRow As Long
    
    Dim rRangeTocheck As Range
    
    Dim rCell As Range
    
'   Specify start and end row number and column number where data is located.
    iFirstRow = 1
    iFirstCol = 1
    
    iLastCol = 3
    iLastRow = 5
    
    With ThisWorkbook.Worksheets("Sheet2")
        Set rRangeTocheck = .Range(.Cells(iFirstRow, iFirstCol), .Cells(iLastRow, iLastCol))
    End With
    
'   Loop though the entire range.
    For Each rCell In rRangeTocheck
    
'       If the cell has an interior color then process it.
        If rCell.Interior.Color <> 0 _
         Then
         
'           If cell is empty then put message into it.
            If rCell.Value = "" _
             Then
                rCell.Value = "Please Fill"
                iUnansweredCount = iUnansweredCount + 1
            
'           If cell is not empty then remove the coloring.
            Else
                rCell.Interior.Pattern = xlNone
            End If

        End If
        
    Next rCell
    
    If iUnansweredCount > 1 _
     Then MsgBox "There are " & iUnansweredCount & " cells to fill-in.", vbInformation

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,853
Messages
6,121,935
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top