ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run when value changes (https://www.excelbanter.com/excel-programming/320561-run-when-value-changes.html)

choice[_2_]

run when value changes
 
how do i get a code to run when i change the value in a cell?

cell a1 is blank, i enter 1 "codeone" runs, i enter 2 "codetwo" runs

thanks in advance

Don Lloyd

run when value changes
 
The following code, placed in the Worksheet Module - (right-click the sheet
tab and select View Code) should start you off. If the the cell changed is
A1 (row 1, column 1) it calls subs depending on the value entered. 1 -
CodeOne etc.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
Select Case Target.Value
Case 1
CodeOne
Case 2
CodeTwo
Case 3
CodeThree
End Select
End If
End Sub


regards,
Don
"choice" wrote in message
...
how do i get a code to run when i change the value in a cell?

cell a1 is blank, i enter 1 "codeone" runs, i enter 2 "codetwo" runs

thanks in advance




choice[_2_]

run when value changes
 
not working for some reason, im not sure if i understand the Cases that well
in EP3 i have a drop down list..values are (Utilities, Paychecks, Other)

if Utilities is selected application.run "code1"
if Paychecks is selected application.run "code2"
if Other is selected application.run "code3"

so do i put case "Utilities":
application.run "code1" ?

"Don Lloyd" wrote:

The following code, placed in the Worksheet Module - (right-click the sheet
tab and select View Code) should start you off. If the the cell changed is
A1 (row 1, column 1) it calls subs depending on the value entered. 1 -
CodeOne etc.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
Select Case Target.Value
Case 1
CodeOne
Case 2
CodeTwo
Case 3
CodeThree
End Select
End If
End Sub


regards,
Don
"choice" wrote in message
...
how do i get a code to run when i change the value in a cell?

cell a1 is blank, i enter 1 "codeone" runs, i enter 2 "codetwo" runs

thanks in advance






All times are GMT +1. The time now is 11:18 PM.

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