Popup a message box the value of different cells of the same row using a macro in an excel report

When I have to present my report, in some of them, I like that when I click a cell, a message box pops out.If you are looking for a validation message, read Popup a validation message the cell value using a macro in an excel report.

macro excel


When I use the macro ?

To popup a message when I click on a specific cell.


How to create the macro ?

Read How to create, edit, hide and select a macro in an excel report


How to create the button to associate it with the macro ?

Read How to create a button and associated it to a macro in an excel report


How to use the macro ?

This macro should be used always with Worksheet_SelectionChange(ByVal Target As Range) and it needs to be put in the corresponding sheet.

macro excel


How is the macro ?

Copy the code below and paste it into your macro. You will see my comments in green if exist so follow the help to adapt to your need.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
i = 1
' change 1 = A by the column number where each time you click, a popup comes out
If Target.Column = 1 Then
' changefirst 1 = A by the same column number ' change second 1 = A and 3 = C by the column number about which data you want to display
If Not IsEmpty(Target.Cells(i, 1)) Then _
MsgBox "ID: " &Target.Cells(i, 1) & vbNewLine & _
"Description: "&Target.Cells(i, 3)
' to put a title for the msgbox, at the end of this line above put: , vbOKOnly, "my title"
End If
End Sub

So if the cells in the column A have a value, each time, I click in one of the cells, a message will come out, showing the value of other cells in the same row. For more options, check the Microsoft MsgBox webpage.

Interesting Management