View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Event Procedure again

This assumes the A A A B C C C E 0
is in row 1 starting in F1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cell As Range
Dim rw As Range
If Target.Count 1 Then Exit Sub
If Target.Value = 1 Then
Application.EnableEvents = False
On Error GoTo ErrHandler
sTarget = Target.Offset(-1, 0).Value
rw = Target.Row
Set rng = Range("F1:N1")
For Each cell In rng
If cell.Value = sTarget Then
Cells(rw, cell.Column).Formula = "=Trunc(rand()*100+1)"
End If
Next
End If
ErrHandler:
Application.EnableEvents = True
End Sub

Right click on the sheet Tab, select view code and paste in the code.
Replace my formula with whatever formula you want.

--
Regards,
Tom Ogilvy


"Paul Johnson" wrote in message
...
My last post was not so clear, as the formats were removed.

What I am trying to do is:

Write an event procedure, upon entering a "1" in a field, this matches the
column header against a corresponding set of data all on one row, and for
every match returns a formula on the same row as the 1 entered in the

column
the match happened.
My Match headers are A,B,C, etc.
I hope this is clearer.
Many thanks for your help.
Paul