Loop not quite working correctly
Want to list the cell address in range OneRng of each blank.
As is, it list the first blank cell address only, but for as many times as there are cells in OneRng.
Thanks.
Howard
Sub OneRng_List_Blanks()
Dim c As Range, Rng As Range
Dim cBlnk$, sMsg$, vDataOut$
Dim blnkFnd As Boolean
Dim i As Long
Dim OneRng As Range, c As Range
Set OneRng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
'For Each c In OneRng
Set Rng = OneRng.Find(What:="", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)
If Not Rng Is Nothing Then
blnkFnd = True
cBlnk = cBlnk & " " & Rng.Address
End If
'Next c
Next i
If blnkFnd Then
sMsg = "Blanks found on the following cells:"
sMsg = sMsg & vbLf & vbLf
sMsg = sMsg & Join(Split(Mid(cBlnk, 2), ","), vbLf)
Else
'Exit Sub
sMsg = "Blanks not found"
End If
MsgBox sMsg
End Sub
|