Computing.Net > Forums > Office Software > Excel Worksheet_Change Event

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel Worksheet_Change Event

Reply to Message Icon

Name: Sammy100
Date: November 22, 2003 at 17:05:37 Pacific
OS: Win 98 (2nd Ed)
CPU/Ram: 256MB
Comment:

Question 1
The code below does exactly what I want it to do when using it on the same sheet.
i.e. If a number greater than zero is entered into cell B5 on the current sheet (sheet1), the word “Red” will be entered into cell E7 on the current sheet (sheet1).
Does anyone know how to modify this so that “Red” is entered into cell E7 on sheet2 (same workbook)?

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("B5")) Is Nothing Then
If Target.Value > 0 Then
Application.ActiveSheet.Range("E7") = "Red"
End If
End If
End Sub

Question 2
Is there a bit of code that would perform the same operation on numbers entered into any of three different cells or would three separate change events have to be set up to do this?
e.g.
If a number > 0 is entered into cell B5, enter the word “Red” into cell E7
If a number > 0 is entered into cell D6, enter the word “Blue” into cell E7
If a number > 0 is entered into cell E2, enter the word “Green” into cell E7

Question 3
When I put two Worksheet_Change macros on the same sheet the following message appears when I try to run either one of them: “Compile error: Ambiguous name detected: Worksheet_Change”. But they both work fine when stored/run on their own. Is it not possible to have more than one Worksheet_Change event on one sheet?




Sponsored Link
Ads by Google

Response Number 1
Name: taxi
Date: November 24, 2003 at 01:07:48 Pacific
Reply:

Can make it without code. An if functiun with a vlookup could do the job.


0

Response Number 2
Name: A Certain TH
Date: November 24, 2003 at 02:59:36 Pacific
Reply:

taxi is right - you could do this very simply without code. If you INSIST on using code, then post back and its easily doable.

For your 3rd question, though:

Yes. It is NOT possible. Logically, it would be like having a light switch which turned a light bulb on and off simultaneously.

However, You can put the code from one into the other and then both will run consecutively.

Tom


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel Worksheet_Change Event

Excel Formatting Colors www.computing.net/answers/office/excel-formatting-colors/6855.html

link 2 copies of excel on 2 machine www.computing.net/answers/office/link-2-copies-of-excel-on-2-machine/8538.html

copy and keep updating www.computing.net/answers/office/copy-and-keep-updating/9356.html