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 26th, 2002, 06:17 AM   #1
kotting
New Member
 
Join Date: Mar 2002
Posts: 17
Default

I currently have a macro that starts when a change is made in a specific range on the worksheet.

My problem is that the macro runs for every cell in the range.

Sample - BT7 value changes to 4. Then the macro is triggered. It compares each cell value in the range to a set of criteria. I only want that specific cell to be recognized because only that cells data changed.

Currently I use "If then" statements to direct from the Worksheet code to six separate 'sub' statements in macros.

The data in the defined range will continue to change as the worksheet is used so i can't compare to a predetermined value.

Is there any hope?

Thanks Again
kotting is offline   Reply With Quote
Old Mar 26th, 2002, 06:23 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi

Question on this:
The data in the defined range will continue to change as the worksheet is used so i can't compare to a predetermined value.
Do you need to reference a cell to gather the conditional value?
Paste a sample of your code and the cell references which the code needs in order to make a decision.
Give as much detail as your willing to give and I guarantee someone in here can solve your problem...

Try this for now.
Place a condition on running your macro...
in change event


If target.row = 7 and _
target.column = 72 then'the 72 is Colum BT
RunMyMacro
end if

Have a nice day
Tom


[ This Message was edited by: TsTom on 2002-03-26 05:34 ]
Tom Schreiner is offline   Reply With Quote
Old Mar 26th, 2002, 06:32 AM   #3
kotting
New Member
 
Join Date: Mar 2002
Posts: 17
Default

Thanks TsTom,

I'll go that direction. Nice of you to help me out!

kotting is offline   Reply With Quote
Old Mar 26th, 2002, 06:38 AM   #4
Dave Hawley
Banned
 
Join Date: Feb 2002
Posts: 1,582
Default

Hi

If the Worksheet_Change event, try

If Not Itersect(Target, Range("A1:D20")) Is Nothing Then
'Do It!
End If
Dave Hawley is offline   Reply With Quote
Old Mar 26th, 2002, 07:51 AM   #5
kotting
New Member
 
Join Date: Mar 2002
Posts: 17
Default

OK, TsTom here is my code. . . .beware that I am a novice and working at learning as I go. This is probably far from optimal.

NOTE - I use =counta(E7:H7, I11:L11, M15:P15) in cell BT7 and other ranges in BT8 and so on. . . .


*****************************************************************************************
Private Sub Worksheet_Change(ByVal Target As Range)





If Range("BT7") > 0 And Range("BT7") < 6 Then
Call FillColor
Else: Call Kladblok
End If


If Range("BT8") > 0 And Range("BT8") < 6 Then
Call Fillcolor1
Else: Call Kladblok1
End If


If Range("BT9") > 0 And Range("BT9") < 6 Then
Call Fillcolor2
Else: Call Kladblok2
End If


If Range("CA7") > 0 And Range("CA7") < 6 Then
Call Fillcolor3
Else: Call Kladblok3
End If


If Range("CA8") > 0 And Range("CA8") < 6 Then
Call Fillcolor4
Else: Call Kladblok4
End If


If Range("CA9") > 0 And Range("CA9") < 6 Then
Call Fillcolor5
Else: Call Kladblok5
End If




End Sub

*******************************************************************************************


Option Explicit

Sub Fillcolor1()
'
' Fillcolor1 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'
With Range("E8:F8,E8:H8,I12:L12,M16:P16").Interior
.ColorIndex = 35
.Pattern = xlSolid
End With

End Sub
Sub Kladblok1()
'
' Kladblok1 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'

With Range("E8:H8").Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
With Range("I12:J12,I12:L12,M16:P16").Interior
.ColorIndex = xlNone
End With
End Sub
Sub Fillcolor2()
'
' Fillcolor2 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'
With Range("E9:F9,E9:H9,I13:L13,M17:P17").Interior
.ColorIndex = 36
.Pattern = xlSolid
End With

End Sub
Sub Kladblok2()
'
' Kladblok2 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'
With Range("I13:L13,M17:P17").Interior
.ColorIndex = xlNone
End With
Range("E9:H9").Interior.ColorIndex = 15

End Sub
*********************************************

That is the idea. . . . I tried to add a copy of my spreadsheet but couldn't figure out how.

Thanks for the help.
kotting 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:58 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