ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trigger code (https://www.excelbanter.com/excel-programming/288970-trigger-code.html)

Bourbon[_21_]

Trigger code
 
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.

Doug Broad[_3_]

Trigger code
 
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

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




Bourbon[_22_]

Trigger code
 
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

--
Message posted from http://www.ExcelForum.com


Doug Broad[_3_]

Trigger code
 
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


"Bourbon " wrote in message ...
Look at the template I attached...you will understand then. I believe it
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 you
enter some number..

Thanks,
B.


---
Message posted from http://www.ExcelForum.com/




Bourbon[_23_]

Trigger code
 
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.

Doug Broad[_3_]

Trigger code
 
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


"Bourbon " wrote in message ...
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.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 06:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com