Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have code that I wish to have executed. It works fine, but it runs
regardless of what cell I have entered. I am using: Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Fills exchange rate field based on currency selected Dim x As Integer If Target.Address = "$B$13" Then If Range("e12") = "CDN" Then Range("b13").Value = _ Worksheets("data").Range("c2").Value ElseIf Range("e12") = "USD" Then Range("b13").Value = _ etc. Any advice would be greatly appreciated. Thank you. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Possibly something like this: Selecting a cell will always fire the
event. You just design it to only do work when the correct cells are selected. Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Fills exchange rate field based on currency selected Dim x As Integer If Target.Address < "$B$13" Then exit sub On Error goto ErrHandler Application.EnableEvents = False If Range("e12") = "CDN" Then Range("b13").Value = _ Worksheets("data").Range("c2").Value ElseIf Range("e12") = "USD" Then Range("b13").Value = _ End if ErrHandler: Application.EnableEvents = True End Sub -- Regards, Tom Ogilvy "Alex Mackenzie" wrote in message ... I have code that I wish to have executed. It works fine, but it runs regardless of what cell I have entered. I am using: Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Fills exchange rate field based on currency selected Dim x As Integer If Target.Address = "$B$13" Then If Range("e12") = "CDN" Then Range("b13").Value = _ Worksheets("data").Range("c2").Value ElseIf Range("e12") = "USD" Then Range("b13").Value = _ etc. Any advice would be greatly appreciated. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stop Worksheet_SelectionChange event from firing? | Excel Programming | |||
worksheet_SelectionChange Event | Excel Programming | |||
Worksheet_SelectionChange Event | Excel Programming | |||
Re : Excel event handler Worksheet_SelectionChange | Excel Programming | |||
Re : Excel event handler Worksheet_SelectionChange | Excel Programming |