Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup message in Excel 1

Status
Not open for further replies.

childrenfirst

Technical User
Oct 15, 2006
80
US
Hi,

I have a macro which highlights selected cell and also displays a pop up message when a cell is selected. My I would like to modify it so that it only highlights the cell and shows popup message when a cell in column, AD, is selected. How should I revise the macro I have?

Here is what I have so far:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 6 ' yellow - change as needed
MsgBox "Display popup!",vbOkOnly
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static OldRange As Range
On Error Resume Next
If Target.Column = 30 Then
Target.Interior.ColorIndex = 6 ' yellow - change as needed
MsgBox "Display popup!", vbOKOnly
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target
End If
End Sub


[yinyang] Tranpkp [pc2]
 
I figured it out now...

The revised code is:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

If Not Intersect(Target, Range("AD1:AD5000")) Is Nothing Then
Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 6 ' yellow - change as needed
MsgBox "Select and pop message!"
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target
End If

End Sub
 
Hi Tranpkp,

I guess I posted mine second message before I saw yours. Your solution is definitely smarter:)

Thanks a bunch! Have a great evening:D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top