Msgbox Question

  • I have the following, which returns a message box every time the code encounters the criteria. I would like to return only one message box at the conclusion of the sub which presents everything that meets the criteria. What's the best way to do this? Is there a way to have the program store those values that meet the criteria and return them at the end? Thanks in advance.


  • Re: Msgbox Question



    but you may end up with a huge message box depending on how many items are found... That can be coded for but simple example above.

  • Re: Msgbox Question


    Great, thank you. Can you please explain what the following line does? I assume this is what is storing the values. I tried the code without the "msg" after the equals sign, so it looked like this msg = c.Text & vbCrLf , but it only returned one value, so I am curious how this line works and what the significance of each element of it is. Thanks for your time.


    msg = msg & c.Text & vbCrLf

  • Re: Msgbox Question


    It stores the current content of the msg variable plus the contents of the cell with a new line appended each time it executes.


    First time around msg is empty so just the cell contents and a new line get stored.
    Next time, the cells contents and a new line are appended to the contents of msg and so on.


    If it only reports 1 item then that's all that was found. Am assuming your comment "msg = c.Text & vbCrLf" was a typo as that will only store the last item found

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!