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.
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.
How is/are the macro(s) ?
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 Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...