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 1st, 2002, 12:48 PM   #1
prometheus
New Member
 
Join Date: Feb 2002
Posts: 45
Default

I have a worksheet which contains information in rows based on a patients weight. The range of weight is entered in column A (A3:A100). I would like to be able to have the user input a patient's weight in a cell (say A2) and then have the speadsheet scroll automatically to that corresponding row and then highlight just that row (or all rows except the desired row. Thanks in advance!
prometheus is offline   Reply With Quote
Old Mar 1st, 2002, 03:42 PM   #2
Joe Was
MrExcel MVP
 
Joe Was's Avatar
 
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
Default

Right click the sheet tab lable, select "View Code" then paste a copy of the code below to the sheet module. JSW

Sub myColor()
'By Joe Was, 2/2002.
'This code will find the cell(s) colored by the myWeight sub below.
Dim myRowNum As Long
myRowNum = ActiveSheet.UsedRange.Rows.Count
Selection.Select
Do Until Selection.Row = myRowNum + 1
If Selection.Interior.ColorIndex <> xlNone Then
'To select entire row, un-comment below!
'Selection.EntireRow.Select
GoTo mySelect
Else
Selection.Offset(1, 0).Select
End If
Loop
End
mySelect:

End Sub


Sub myWeight()
'By Joe Was, 2/2002.
'This code will find the value entered in A2 on sheet1.
'Change "Worksheets( ) to your sheet number below.
Application.ScreenUpdating = False
With Worksheets(1).Range("A3:A100")
Set c = .Find(Worksheets(1).Range("A2"), LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.ColorIndex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

Application.ScreenUpdating = True
End Sub

You will run this code with a form button or hot-key option. Tools, Macro, Macros, Options then add your hot key letter. The sub's will find and color all the cells that match the find value, the myColor sub can be re-run to find the next colored cell.

You could add code to reset the colored cells to noColor or just don't save the workbook after the cells have been colored?
JSW

[ This Message was edited by: Joe Was on 2002-03-01 14:44 ]
Joe Was is offline   Reply With Quote
Old Mar 4th, 2002, 05:42 AM   #3
prometheus
New Member
 
Join Date: Feb 2002
Posts: 45
Default

Joe, Thanks for the "my weight" and "my color" macros. If you recall I had a series of patient weights in column A and needed to highlight and scroll to the row with the user entered weight. The selected cell was colored yellow by you macro. Unfortunately, the macros did not scroll the sheet automatically to the selected (colored) row. I'd appreciate if you could try to fix the macros so that the worksheet will scroll automatically to the selected (colored) cell. I appreciate your help. I've always accomplished what I wanted to do with macros in the past and I am not proficient with writing visual basic code. The weights in the worksheet are now in column A range A5:A100. I am now entering the desired weight in cell F2 instead of A2. Thanks for your time!
prometheus 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 02:36 AM.


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