Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Event Procedure again

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
workbook_Open event Procedure peerless Excel Discussion (Misc queries) 0 May 22nd 06 10:16 PM
Event Procedure Paul Johnson[_2_] Excel Programming 1 February 2nd 05 01:29 PM
change event procedure benb Excel Programming 2 September 24th 04 09:22 PM
Event Procedure Programming Jeff Armstrong Excel Programming 1 July 29th 04 03:54 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 12:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"