Tech Support Guy banner

Excel Macro Advice - MsgBox Value

9969 Views 5 Replies 3 Participants Last post by  Zack Barresse
I am trying to generate a Message Box with a changing value in the text that references a cell value. For example, if there are 2 errors on a worksheet (reflected by a "2" in cell A1), I want the MsgBox to say "You have 2 errors on this page". And if there are 12 errors (with a "12" already in cell A1), "You have 12 errors on this page". Can someone help me please?
Status
Not open for further replies.
1 - 2 of 6 Posts
Again, assuming that the number of errors is in cell A1

Sub Macro1()

MsgBox ("You have " & Range("A1").Value & " errors on this page.")

End Sub
You must have me confused with someone who actually knows what they are doing! That being said, I do have an EXCEEDINGLY complicated array formula which I borrowed from some true genious a number of years ago (the exact source being long lost in my failing memory) that does something like what you want. If you are unfamiliar with array formulae, you would be well advised to look it up in Microsoft Help. When that further confuses you, the only thing you really need to know is that it works like a regular formula, except on a group of cells where you would normally specify a single cell. And to get it to work, you have to type in the formula and then press CTRL+SHIFT+ENTER (all at the same time) when it is entered correctly. Typing just ENTER guarantees that the formula won't work. I have attached a worksheet that has what you want. Enter anything you want in A1:A10 and it will appear in the same order in B1:B10, minus any holes or blanks. Now, if you try to figure out the array formulae in B1:B10, I can almost guarantee that you will qualify for the State Home for the Mentally Bewildered before you figure it out. But it works, so don't argue with success. You can copy it and (carefully) put it in another worksheet, substituting the appropriate ranges for A1:A10 and B1:B10. Then just hit CTRL+SHIFT+ENTER and you have your solution. Now, the Msgbox part is left as an exercise for the interested student. Good luck.

Attachments

See less See more
1 - 2 of 6 Posts
Status
Not open for further replies.
Top