N
ned
Hello;
I can not figure out why the following code will not work.
The range "LamTable" has data validation set to allow only items from a
list, or a blank. I want to change the cell to a blank when the user
selects "<none>" from the list. I also want to change the value in the
corresponding row of the range "LamMultipliers" to 0.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo theEnd
Application.EnableEvents = False
If Not (Application.Intersect(Target, Me.[LamTable]) Is Nothing) Then
If Target.Value = "<none>" Then
ActiveSheet.Cells(1, 1) = "Hello" 'error occurs here
Me.Cells(Target.Row, Target.Column).Formula = ""
Me.Cells(Target.Row, Me.[LamMultipliers].Column) = 0#
End If
End If
theEnd:
Application.EnableEvents = True
End Sub
I have spent about 4 hours trying different methods to accomplish the same
thing and none of them work.
The code gets the correct cells - I checked using the debugger. An error
1004 is raised whenever the code tries to modify any cell on the sheet. The
sheet is not protected.
--
Thanks in advance,
Stephen
____________________________________________________________________________
____
S. Fitzgerald, P.Eng, MASc.
Practical Composites, Inc.
Halifax, NS
Canada
I can not figure out why the following code will not work.
The range "LamTable" has data validation set to allow only items from a
list, or a blank. I want to change the cell to a blank when the user
selects "<none>" from the list. I also want to change the value in the
corresponding row of the range "LamMultipliers" to 0.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo theEnd
Application.EnableEvents = False
If Not (Application.Intersect(Target, Me.[LamTable]) Is Nothing) Then
If Target.Value = "<none>" Then
ActiveSheet.Cells(1, 1) = "Hello" 'error occurs here
Me.Cells(Target.Row, Target.Column).Formula = ""
Me.Cells(Target.Row, Me.[LamMultipliers].Column) = 0#
End If
End If
theEnd:
Application.EnableEvents = True
End Sub
I have spent about 4 hours trying different methods to accomplish the same
thing and none of them work.
The code gets the correct cells - I checked using the debugger. An error
1004 is raised whenever the code tries to modify any cell on the sheet. The
sheet is not protected.
--
Thanks in advance,
Stephen
____________________________________________________________________________
____
S. Fitzgerald, P.Eng, MASc.
Practical Composites, Inc.
Halifax, NS
Canada