TheTiredEngineer
New Member
- Joined
- Jul 31, 2024
- Messages
- 31
- Office Version
- 365
- Platform
- Windows
OK so I have this bit of code that Im trying to figure out. Im hoping for a quick resolution.
if I want to pair this code with an if loop to check each drop down is Y or N and then only count blanks that are in the same section as that Y/N? I imagine it will be a for loop to count the drop-down rows and an if statement to check if Y. Can I pair that with the Len(rngCell.Formula)=0 ? Currently its checking all the blanks and obviously if the dropdown in N, then I dont want it checking those cells. Ive tried a few different For loops today and I kept getting stuck in infinite loops and it wasnt working.
VBA Code:
Option Explicit
Dim MyRange, MR, rngCell As Range
Dim rngCol, c, lockRange, lockCell As Range
Dim rngCount, TotalBlanks, LockCount As Long
Dim rngCellValue As String
Sub CheckEmptyCellsButton_Click()
Set MR = Range("A1:AF184")
Set rngCol = Range("C1:C145")
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 c In rngCol
If c.Value = "Y" Then
Debug.Print "Y cells selected"
End If
Next c
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 Len(rngCell.Formula) = 0 Then 'checks if a cell is blank
TotalBlanks = TotalBlanks + 1
Debug.Print rngCell.Address & " is blank"
Debug.Print TotalBlanks
End If
End If
Next rngCell
End Sub
if I want to pair this code with an if loop to check each drop down is Y or N and then only count blanks that are in the same section as that Y/N? I imagine it will be a for loop to count the drop-down rows and an if statement to check if Y. Can I pair that with the Len(rngCell.Formula)=0 ? Currently its checking all the blanks and obviously if the dropdown in N, then I dont want it checking those cells. Ive tried a few different For loops today and I kept getting stuck in infinite loops and it wasnt working.