Msg Box -VBA code

I have 2 different worksheets:

·         worksheet-1

·         worksheet-2

I want msgbox in worksheet-1 referring to values in worksheet-2.

For example:

In worksheet-1:

| A |

| B |

| C |

In worksheet-2:

| A | 10 | 5  | 6 | 4 |

| B | 5  | 4  | 2 | 1 |

| C | 5  | 10 | 5 | 6 |

When I give key on worksheet-1, it should refer to the values in worksheet-2 and show as a msgbox.

Msg box:

| A  |

| 10 |

| 5  |

| 6  |

| 4  |

 

 

The code I have so far is:

Sub Search()

    Msg = “CALL DETAILS” & vbCr

    For Each cell In Sheets(“sheet1”).Range(“B2:B” & Sheets(“sheet1”).Cells(Rows.Count, “B”).End(xlUp).Row)

        If LCase(cell.Value) = LCase(Selection.Value) Or InStr(1, LCase(cell.Value), _

            LCase(Selection.Value)) > 0 Then

                Msg = Msg & vbCr & cell.Offset(0, 1) & ” / “ & vbCr & cell.Offset(0, 2) & ” / “ & cell.Value

        End If

    Next

    i = MsgBox(Msg, vbInformation)

End Sub

 

By: Naresh

3,553 thoughts on “Msg Box -VBA code

  1. udfauzi

    Can I just say what a relief to uncover somebody who really understands what they’re discussing over the internet. You actually understand how to bring an issue to light and make it important. More people need to read this and understand this side of your story. I can’t believe you’re not more popular since you certainly possess the gift.

  2. iamgutsclub

    May I just say what a comfort to uncover somebody who actually understands what they are discussing over the internet. You definitely know how to bring a problem to light and make it important. A lot more people ought to check this out and understand this side of your story. I can’t believe you’re not more popular because you surely possess the gift.

Comments are closed.