TheTiredEngineer
New Member
- Joined
- Jul 31, 2024
- Messages
- 31
- Office Version
- 365
- Platform
- Windows
Hello
Im trying to get my excel vba to search for all the cells that are filled with a tan color and then find within those the cells that are empty. So far its been listing all the cells that are filled with a tan color and ignoring my code to check for only empty cells. Some cells are supposed to have numbers, and some are text. Any help is appreciated.
Im trying to get my excel vba to search for all the cells that are filled with a tan color and then find within those the cells that are empty. So far its been listing all the cells that are filled with a tan color and ignoring my code to check for only empty cells. Some cells are supposed to have numbers, and some are text. Any help is appreciated.
VBA Code:
Option Explicit
Dim MyRange, MR, rngCell, rngCol As Range
Dim rngCount, TotalBlanks As Long
Dim rngCellValue As String
Sub Button19_Click()
Set MR = Range("A1:AF184")
rngCount = 1
TotalBlanks = 1
'Need a second For Each loop to select each of the Y/N boxes and compare if Y, then check if cells are blank
For Each rngCell In MR
If rngCell.DisplayFormat.Interior.Color = RGB(255, 245, 217) Then
'Sheets("Results").Range("A" & rngCount) = rngCell.Value
rngCount = rngCount + 1 'counts the number of fillable yellow cells
If rngCell.Value <> vbNullString Then 'checks if a cell is blank
TotalBlanks = TotalBlanks + 1
Debug.Print rngCell.Address & " is blank"
Debug.Print TotalBlanks
'Debug.Print rngCount
'Debug.Print rngCell.Value
End If
End If
Next rngCell
End Sub