MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 20th, 2002, 03:56 AM   #1
ClaesB
New Member
 
Join Date: Mar 2002
Location: Karlstad, Sweden
Posts: 5
Default

I Have a case where I want a macro to start whenever a certain cells changes, regardless of reason for cell change (i.e. user input or link change.
According to Excel Help, Worksheet_Change() should be my ideal solution, but it doesn't seem to fire when the value in linked cells changes.
Workbook_Calculate was another shot I tried, but I can't see an easy way to determine whether my cells of interest are changed or not.
ClaesB is offline   Reply With Quote
Old Mar 20th, 2002, 04:03 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi

This is fun

Eventhough I might be wrong

I do believe that links are governed by the Workbook and not individual sheet modules. Try this event here:
Notice (((WORKBOOK)))_SheetChange

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

End Sub
Tom Schreiner is offline   Reply With Quote
Old Mar 20th, 2002, 04:17 AM   #3
ClaesB
New Member
 
Join Date: Mar 2002
Location: Karlstad, Sweden
Posts: 5
Default

Instant response !! Thanks !

I have tried workbook_change() also. The problem is that it does not seem to trig on links either. Example: On Sheet1 I have a cell (A2) containing a link to a cell (B2) on Sheet2. Changing the value in cell B2 on Sheet2 does fire workbook_change, but the target is Sheet2!B2.
I would need an event with target Sheet1!A2. But I cannot see that this happens.

Have also tried linking to another workbook, and changing the source in that workbook, does not trig the event (in the first wkb) at all.

Ok, I think I can solve my problem by using Worksheet_Calculate, but not without some dirty coding to determine if certain cell values are changed or not.

Btw, are there any Excel settings that might be set to disable event on links ?

/Claes
ClaesB is offline   Reply With Quote
Old Mar 20th, 2002, 04:18 AM   #4
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

This is the help file from Office 2000

SheetChange Event


Occurs when cells in any worksheet are changed by the user or by an external link.

Syntax

Private Sub object_SheetChange(ByVal Sh As Object, ByVal Source As Range)

object Application or Workbook. For more information about using events with the Application object, see Using Events with the Application Object.

Sh A Worksheet object that represents the sheet.

Source The changed range.

Remarks

This event doesn't occur on chart sheets.
Tom Schreiner is offline   Reply With Quote
Old Mar 20th, 2002, 04:20 AM   #5
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

On your Worksheet Menu Bar
Click Tools
Options
Calculation Tab

Check your workbook Options at the bottom...
Tom Schreiner is offline   Reply With Quote
Old Mar 20th, 2002, 04:22 AM   #6
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Sorry, I misunserstood you

internal links(calculations) do not set off any change events. You will have to trap it in the calculate event like you already figured...
Tom Schreiner is offline   Reply With Quote
Old Mar 20th, 2002, 04:27 AM   #7
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

I tried what you are trying to do and the macro did fire when Sheet2 B2 was changed by Sheet1 A2

Are you calling the macro correctly???

If not, you just simply list the macro name in the calculate_event.
Tom Schreiner is offline   Reply With Quote
Old Mar 20th, 2002, 04:32 AM   #8
ClaesB
New Member
 
Join Date: Mar 2002
Location: Karlstad, Sweden
Posts: 5
Default

I appreciate Your help !

Did you use Workbook_change ?
My eventcode looks like this:
-------------------
Private Sub Workbook_SheetChange(ByVal objSheet As Object, ByVal rngTarget As Range)
Dim wksSheet As Worksheet

Set wksSheet = objSheet

MsgBox ("Sheet:[" & wksSheet.Name & "] Range:[" & rngTarget.AddressLocal & "]")

Set wksSheet = Nothing

End Sub
-------------------

When I change the value in Sheet2!B2, the target in my event is Sheet2!B2.
I would like to get an event where target is Sheet1!A2.

/Claes


ClaesB is offline   Reply With Quote
Old Mar 20th, 2002, 04:44 AM   #9
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Here is all I did

In the sheet where the change is being trapped.

Private Sub Worksheet_Calculate()
MacroNameHere
End Sub

That should be all you have to do.

Just in case were getting stuck.
When a value is typed into a cell, you must exit the cell before any events or calculations occur

A little more detail. I might have it backwards, but you'll get the jist of it

Here is my calc link

this formula is in cell Sheet2 B2
=Sheet1!A2

when i change the value in sheet1 A2 and exit the cell, sheet2 B2 calculates and runs your macro. The calculate event is in sheet 2?

I hope this helps
Tom Schreiner is offline   Reply With Quote
Old Mar 20th, 2002, 05:06 AM   #10
ClaesB
New Member
 
Join Date: Mar 2002
Location: Karlstad, Sweden
Posts: 5
Default

Well, when using the Calculate event my problem is not to get it fired, but to find out if the cells of interest,let's say Col 1, has changed or not.

The original case was to run a macro (that plays a sound), whenever certain cells (Column 1) is changed.

By using the calculate event I guess I have do some coding to determine if cells are changed or not (i.e. save prev values in hidden column, and then compare upon calcuate event)

Ok, this might be the only solution, but it would be nice to find an easier one ...

/Claes
ClaesB is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes