tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
The code below lists the address of all cells in a pre-defined range whose value is zero.
What I want is to have the message box display the addresses in a list going down, instead of in a single continuous sentence, ie I want:
instead of:
How can it be done?
Thanks
[/FONT]
Rich (BB code):
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Dim Rng As Range
With ws
Set Rng = .Range(.Cells(1, 1), .Cells(1,1000))
End With
Dim ZeroColl As Collection
Set ZeroColl = New Collection
Dim RngElement As Range
For Each RngElement In Rng
If RngElement.Value = 0 Then ZeroColl.Add RngElement.Address
Next RngElement
Dim ZeroCollCount As Long
ZeroCollCount = ZeroColl.Count
Dim i As Long
Dim j As String
For i = 1 To ZeroCollCount
j = j & "," & ZeroColl(i)
Next i
Set Rng = Nothing
Set RngElement = Nothing
MsgBox " These cells are empty:" & vbNewLine & vbNewLine & Right(j, Len(j) - 1)
What I want is to have the message box display the addresses in a list going down, instead of in a single continuous sentence, ie I want:
Rich (BB code):
A20
A25
A33
instead of:
Rich (BB code):
A20, A25, A33
How can it be done?
Thanks
[/FONT]