5

I am trying to get the result of different cells based on a preset if statement I am receiving the result in multiple message boxes, and the result for all cells is being calculated based on the first statement check up. How can i receive all results in a single msgboxand allow the function to check every single cell in the range?

Dim rcell As Range
For Each rcell In Vou_Summary.Range("I5:I16")
    If 0 < rcell <= 2.5 Then
        MsgBox rcell.Cells.Offset(0, -3).Value & " Is Critical", vbOKOnly, "Notice!"
    ElseIf 2.5 < rcell <= 4 Then
        MsgBox rcell.Cells.Offset(0, -3).Value & " Requires PR Placement", vbOKOnly, "Notice!"
    ElseIf rcell >= 7 Then
        MsgBox rcell.Cells.Offset(0, -3).Value & " Is Oversupplied", vbOKOnly, "Notice!"
    Else
End If
Next

1 Answer 1

3

You can create a String variable first. Don't throw a MsgBox but save the results into the variable. Past the End If statement show the MsgBox and pass the string variable as the content.

Better, you can use a String Builder to make it work about 1000 times faster than the default VBA concatenation ;)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.