cell activate show pop up "box" with a range of cell values

zrx1200

Well-known Member
Joined
Apr 14, 2010
Messages
622
Office Version
  1. 2019
Platform
  1. Windows
I would like to have a macro fire automatic when any cell in a column is highlighted. this would then bring a range of 10 cells of this row into a pop up to show values of theses cells.

Any direction would be much appreciated.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I would like to have a macro fire automatic when any cell in a column is highlighted. this would then bring a range of 10 cells of this row into a pop up to show values of theses cells.

Any direction would be much appreciated.

Copy this code to your worksheet code module.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A:A")) Is Nothing Then
    For i = 2 To 11
        msg = msg & Cells(Target.Row, i).Value & ", "
    Next
    MsgBox msg
End If
End Sub
 
Upvote 0
Copy this code to your worksheet code module.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A:A")) Is Nothing Then
    For i = 2 To 11
        msg = msg & Cells(Target.Row, i).Value & ", "
    Next
    MsgBox msg
End If
End Sub

Thanks for reply! Here is my revised addition, works great!

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Long
Dim msg As Variant, Lngcounter As Integer
If Target.Cells.count > 1 Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
    For i = 4 To 13
        Lngcounter = Lngcounter + 1
        msg = msg & Lngcounter & "  " & Cells(Target.row, i).value & vbCrLf     ' ", "
    Next
    MsgBox msg
End If
End Sub
 
Upvote 0
Thanks for reply! Here is my revised addition, works great!

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Long
Dim msg As Variant, Lngcounter As Integer
If Target.Cells.count > 1 Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
    For i = 4 To 13
        Lngcounter = Lngcounter + 1
        msg = msg & Lngcounter & "  " & Cells(Target.row, i).value & vbCrLf     ' ", "
    Next
    MsgBox msg
End If
End Sub

Thanks for the feed back,
Regards, JLG
 
Upvote 0
Thanks for the feed back,
Regards, JLG

Trying to push further... This will add a time found to the list but fails error 1004 unable to get vlookup property of worksheet class ???

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Long
Dim msg As Variant, Lngcounter As Integer
Dim DeliveryTime As Variant
Dim Lookup_Range As Range
Set Lookup_Range = Worksheets("Data").Range("A2:D195")
Dim thisvalue As String
If Target.Cells.count > 1 Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
 
    For i = 4 To 13
'      thisvalue = Cells(Target.row, i).value
'       DeliveryTime = Application.WorksheetFunction.VLookup(thisvalue, Lookup_Range, 2, False)
        Lngcounter = Lngcounter + 1
        msg = msg & Lngcounter & "  " & Cells(Target.row, i).value & vbCrLf & "  " & Application.WorksheetFunction.VLookup(Cells(Target.row, i).value, Lookup_Range, 2, False)
'        thisvalue = ""
    Next
    MsgBox msg
End If
End Sub
 
Upvote 0
Trying to push further... This will add a time found to the list but fails error 1004 unable to get vlookup property of worksheet class ???

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Long
Dim msg As Variant, Lngcounter As Integer
Dim DeliveryTime As Variant
Dim Lookup_Range As Range
Set Lookup_Range = Worksheets("Data").Range("A2:D195")
Dim thisvalue As String
If Target.Cells.count > 1 Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
 
    For i = 4 To 13
'      thisvalue = Cells(Target.row, i).value
'       DeliveryTime = Application.WorksheetFunction.VLookup(thisvalue, Lookup_Range, 2, False)
        Lngcounter = Lngcounter + 1
        msg = msg & Lngcounter & "  " & Cells(Target.row, i).value & vbCrLf & "  " & Application.WorksheetFunction.VLookup(Cells(Target.row, i).value, Lookup_Range, 2, False)
'        thisvalue = ""
    Next
    MsgBox msg
End If
End Sub

Solved.

The value if nothing was causing error. Solution in code.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Long
Dim msg As Variant, Lngcounter As Integer
Dim DeliveryTime As Variant
Dim Lookup_Range As Range
Set Lookup_Range = Worksheets("Data").Range("A2:D195")
Dim thisvalue As String
If Target.Cells.count > 1 Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
 
    For i = 4 To 13
      thisvalue = Cells(Target.row, i).value
      If thisvalue = "" Then Exit For
       DeliveryTime = Application.WorksheetFunction.VLookup(thisvalue, Lookup_Range, 3, False)
        Lngcounter = Lngcounter + 1
        msg = msg & Lngcounter & "  " & Cells(Target.row, i).value & "      " & Format(DeliveryTime, "h:mm ") & vbCrLf
'        thisvalue = ""
    Next
    MsgBox msg
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top