View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Worksheet change doesn't look at code

On Oct 21, 11:18 am, JW wrote:
On Oct 21, 11:08 am, "Jeff Wright" wrote:



Good morning!


I have the following code in my program. When I change the contents of cell
M16, I expect that this code will be activated. However, the program doesn't
even look at it. Am I doing something wrong??


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Worksheets("EDGING").Range("M16") = "BEVEL" Then
Worksheets("EDGING").Range("A102") = "BevelRadius"
ElseIf Worksheets("EDGING").Range("M16") = "PENCIL POLISH" Or _
Worksheets("EDGING").Range("M16") = "HIGH FLAT POLISH" Then
Worksheets("EDGING").Range("A102") = "FlatPencilRadius"
Else: Worksheets("EDGING").Range("A102") = "None"
End If
End Sub


Thanks,


Jeff


Well, this is odd. My name is Jeff Wright too.

You are using SelectionChange when you should be using Change.
Private Sub Worksheet_Change(ByVal Target As Range)

Also, make sure that the code is placed in the worksheet module.
Right click on the sheet tab where you want this to happen and select
View Code. Then place the code there.


Here is the altered code to be placed in the module of the EDGING
sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("M16") = "BEVEL" Then
Range("A102") = "BevelRadius"
ElseIf Range("M16") = "PENCIL POLISH" Or _
Range("M16") = "HIGH FLAT POLISH" Then
Range("A102") = "FlatPencilRadius"
Else
Range("A102") = "None"
End If
End Sub