Messagebox listing going down instead of across

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,924
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
The code below lists the address of all cells in a pre-defined range whose value is zero.

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]
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
How about
Code:
[FONT=Verdana] j = j & vblf & ZeroColl(i)[/FONT]
 
Upvote 0
Try changing this line:
Code:
[FONT=Verdana]j = j & "," & ZeroColl(i)[/FONT]
to this:
Code:
[FONT=Verdana]j = j & vbCrLf & ZeroColl(i)[/FONT]
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
Messagebox listing going down instead of across (part 2)

Further to my post here:

Rich (BB code):
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]https://www.mrexcel.com/forum/excel-questions/1113228-messagebox-listing-going-down-instead-across.html

I achieved what I wanted with the help from Fluff and Joe4.

However what I find now is the list is very long, to the extent I cannot see the OK button!

Is there way to limit the number of rows and then have the results within the same message box but in column 2?
[/FONT]
At present it looks like this:

Rich (BB code):
A25
A30
A33
A40
A49

but imagine it going on in a single long column.

Instead I would like it as follows:

Rich (BB code):
A25    A40
A30    A49
A33

Is that possible?

Thanks
 
Upvote 0
Re: Messagebox listing going down instead of across (part 2)

I have merged your most recent post back to the original thread.
Directly related follow-ups that are dependent upon the previous question should continue on in the same thread. You should only post to a new thread if it is a new question that is not dependent upon the previous question.
 
Upvote 0
Re: Messagebox listing going down instead of across (part 2)

Thanks.

I thought posting it separately avoided confusion.
 
Upvote 0
Re: Messagebox listing going down instead of across (part 2)

I thought posting it separately avoided confusion.
What confusion?

You have two people helping you. Why would you not want them to continue to help you?
Since they are already invested in your problem, they are some of the most likely people to help you see it through.
By posting to a new thread, they may not see it, so you may not get help from them.

Back to your question, this could get pretty tricky. Let's take a step back.
What is the ultimate goal here? For what purpose do you want to return a a large list of cell addresses to a message box?
What do you mean to do with it? Since it is a message box, it really cannot be used for anything, other than to look at and read.
 
Upvote 0
Re: Messagebox listing going down instead of across (part 2)

I just want the message box to return a list of cell addresses whose values are zero.

Then the user can clean up the data however they wish.

If the message box is not a good idea, I suppose I can paste the results onto a worksheet instead.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top