patsdavixen
New Member
- Joined
- Mar 5, 2013
- Messages
- 32
Hi,
I been working on a macro that highlights all blank cells in a row till the end of a variable range (the number of rows are variable but the columns are limited from A:AI) to be highlighted in purple background using conditional formatting.
What I am struggling with is that I need a macro to show a message box if even one cell in the variable range from A2:AI2 (the number of rows are variable but the columns are limited from A:AI) is blank and is highlighted in the purple colour conditional formatting.
If there are no blank cells in the row, I want it to state "Completed" and if even one cell is blank in the range, it should show a message box stating "Please fill all blank cells highlighted in purple"
The macro should loop until the user updates all blank cells.
Here is the code so far but I can't seem to get the IF function for the macro to loop to work.. It runs all the way to "Completed" even if there are blank cells. With the Exit sub included it doesn't even run till "Completed". Could someone please help me?
This is very urgent so I would appreciate your help.
Thanks,
Pat
I been working on a macro that highlights all blank cells in a row till the end of a variable range (the number of rows are variable but the columns are limited from A:AI) to be highlighted in purple background using conditional formatting.
What I am struggling with is that I need a macro to show a message box if even one cell in the variable range from A2:AI2 (the number of rows are variable but the columns are limited from A:AI) is blank and is highlighted in the purple colour conditional formatting.
If there are no blank cells in the row, I want it to state "Completed" and if even one cell is blank in the range, it should show a message box stating "Please fill all blank cells highlighted in purple"
The macro should loop until the user updates all blank cells.
Here is the code so far but I can't seem to get the IF function for the macro to loop to work.. It runs all the way to "Completed" even if there are blank cells. With the Exit sub included it doesn't even run till "Completed". Could someone please help me?
Code:
Sub chk4blanks()
Dim i As Long, j As Long, lastrow As Long
Dim rng As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
Set rng = Range(Cells(i, 1), Cells(i, 35))
j = Application.WorksheetFunction.CountBlank(rng)
If j > 0 Then
MsgBox "There are [" & j & "] blank cells in [Row " & i & "]. Please fill all blank cells highlighted in purple"
End If
Next i
Exit Sub
If rng = 0 Then
MsgBox "Completed"
End If
End Sub
This is very urgent so I would appreciate your help.
Thanks,
Pat