PDA

View Full Version : worksheet change function



mark_h82
10-10-2006, 07:30 AM
Hi All,

I want to use the worksheet change function but need help.

I have a spreadsheet where if someone types in cell A3, A4, A5 etc, I want to add a formula in to Y3, Y4, Y5 etc. In otherwords, each time someone enters in column A, a formula is entered in column Y for the corresponding row.

Is this possible?

Bob Phillips
10-10-2006, 08:00 AM
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Offset(0,24).Formula = your_formula here
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

mark_h82
10-10-2006, 08:44 AM
thank you, seems to work a treat :)