Trigger code

B

Bourbon

I think this is what is called an event trigger, but how to use?
Columms C to L have data in them from rows 30 to row 68. Each columm i
a different company (thus there are 10 companies). Each columm i
numbered 1 to 10 (thus C has number 1 in row 28, D has number 2 in ro
28, etc)...up to number 10 in columm L row 28.

Columm M and N are empty but I want to trigger an event in ro
28....when I enter for example, number 3(in row 28M) and number 6(i
row 28N), it will copy and paste the data from the correspondin
columms that have does numbers in row 28 into columm M and N...

Any thoughts?
Thanks,
B.

I have attached the template so that you can see what I mean
PS: How do I do it so that the cell M28 and N28 act like "comman
buttons" that when a number is entered, the execute the code

Attachment filename: template.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=41853
 
D

Doug Broad

I am not sure I exactly follow, but, have you considered the
worksheet_change event? You can test the cell address being
changed and the corresponding value in row 28 and use that
to make the changes.

Regards,
Doug


"Bourbon >" wrote in message
 
B

Bourbon

Look at the template I attached...you will understand then. I believe i
is actually quite simply to do but I have never done it before so????

I'ts basically a copy and paste function that is triggered when yo
enter some number..

Thanks,
B
 
D

Doug Broad

Paste this into the Worksheet code section for that sheet. Some of the MVP's
could certainly do better.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range
If Target.Row = 28 And IsNumeric(Target.Value) And Not IsEmpty(Target) Then
For Each cl In Target.EntireRow.Cells
If cl.Value = Target.Value Then GoTo found
Next cl
found:
If cl.Address = Target.Address Then
MsgBox "Company Not Found"
Else
Range(cl, Cells(73, cl.Column)).Copy
Target.PasteSpecial (xlPasteValues)
End If
ElseIf IsEmpty(Target) And Target.Column <> 1 Then
Range(Target, Cells(73, Target.Column)).ClearContents
End If

End Sub
 
B

Bourbon

Doug, like you said, the code was crude but I did the trick and I thank
you very much for it.

If you don't mind, I might have another question about another code
later to ask you....

Thanks again,
B.
 
D

Doug Broad

You're welcome.
For future code questions, just ask the group in a new
thread. I don't hang out here a lot so would be unlikely
to answer in a timely fashion.

Regards,
Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top