Too much string for MsgBox

rjwebgraphix

Well-known Member
Joined
May 25, 2010
Messages
590
On rare occasion, I'm noticing that it is possible that a Msgbox will no longer grow in size and it crops the string.

I'm trying to come up with a good way to deal with this. I have already minized as much data displayed as I possibly can without breaking them into back to back msgbox's.

Is there a way to determine if the message box would crop the string before displaying it?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Can you give an example? Are you breaking the string into multiple lines?

The purpose is a final results message and it is built throughout various places throughout the entire entire code. It is broken into many multiple lines. The results message itself comprises of 3 sections.

1. Newly added stores
2. Bad Prices (based on error in vlookup)
3. Zero Prices (Price in data is already Zero)

Part of this macro it will look at input data and if there are Districts and/or stores that are not currently in the spreadsheet it automatically adds them where appropriate... then the Newly added Stores section is broken down like this...

District: Dist#
Stores: Store numbers, comma separated
Chr(10), Chr(10)

So, if multiple stores in multiple districts have been added, then the Msg gets longer and longer.

The last two have been reduced down to just displaying a message that says there is a bad price or a zero price and to check the log (A sheet named "Log") for specifics on what has the bad price or zero price. Each of these consists of about 5 lines in the msgbox.

In the end I just display the results with

Msgbox (ResultsMsg)

I would show a bit of the code that brings it all together, but I'm at home right now, not at work, and I don't have a copy of it here.

So back to the question at hand. Would there be a way to determine if the Variable ResultsMsg is too big to display all of it?
 
Upvote 0
As far as I am aware a MSgBox can hold a maximum of 1024 characters.

If the strings themselves aren't being cropped do you really need to display it in a MsgBox? Why not print the strings into, for example, a new sheet that way you can present as much data as you need to see. Just an idea. I could ofcourse be wrong about the max length too.
 
Upvote 0
Why not print the strings into, for example, a new sheet that way you can present as much data as you need to see.

I do that already for the Bad Price and Zero Price errors so the user can see exactly which parts on which work orders have errors. Thus, the Log sheet.

I'm just trying to capture a rarity. It can happen, but in most every day to day situations it wouldn't happen.

I'm also doing google searches to verify your max length claim. I think I've already had more than 1024 characters, but I never actually counted them.
 
Upvote 0
Use a userform with one huge comment field and an OK button?

Or a text box with a scroll bar?
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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