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 Apr 12th, 2002, 04:23 AM   #1
Big Tom
New Member
 
Join Date: Apr 2002
Posts: 5
Default

I really really want to know how to propagate a macro from one area to another - if that makes sense...
A simply example: While recording a macro, if i select a line from col B to J, and then turn it bold, how can i write the cell refs so that this simple operation repeats to the next line each time i run the macro (eg by pressing my shortcut key).
Or, if my cursor has highlighted the cell in column A, with my macro i want to select and underline the rest of the row (to J) - but then i want to select another line and have the macro underline this new line and not automatically go back to the original line. Understand????
please help - its driving me mad
Big Tom is offline   Reply With Quote
Old Apr 12th, 2002, 04:25 AM   #2
KnAsTa
Board Regular
 
Join Date: Apr 2002
Location: Australia
Posts: 52
Default

If you know VB you can use a "For loop". Iterating line by line.
KnAsTa is offline   Reply With Quote
Old Apr 12th, 2002, 04:27 AM   #3
Big Tom
New Member
 
Join Date: Apr 2002
Posts: 5
Default

ok ok... a for loop. no i don't know VB but that sounds very useful. i'll try to find it. Thanks alot
Big Tom is offline   Reply With Quote
Old Apr 12th, 2002, 04:29 AM   #4
Big Tom
New Member
 
Join Date: Apr 2002
Posts: 5
Default

actually, i have no idea how to do that... any clues?
Big Tom is offline   Reply With Quote
Old Apr 12th, 2002, 04:29 AM   #5
KnAsTa
Board Regular
 
Join Date: Apr 2002
Location: Australia
Posts: 52
Default

No problem. A for loop just loops a set of code a designated amount of times and then ends. Each time the code loops it can change a value in the set of code, say for you you would change the cell range. Ie if you wanted to go down the cell column you would go A1 (first loop) A2 (second loop) etc
KnAsTa is offline   Reply With Quote
Old Apr 12th, 2002, 04:40 AM   #6
Big Tom
New Member
 
Join Date: Apr 2002
Posts: 5
Default

what i really want to do is have a macro that performs a set of operations on a range of columns in a row and where it doesn't matter what row you've initially selected, be it 1, 15 or 1394.
I need it to ,say, turn it bold or underline it or (for a range) sort it or run a more complex macro on it.
can i not simply write the cell/column syntax slightly differently - like R3C29 or $J$89 or something like that??
sorry to go on, but the rows i need to treat are irregularly spaced out over several thousand lines and maybe a loop might not work?? i'm not sure..
Big Tom is offline   Reply With Quote
Old Apr 12th, 2002, 05:25 AM   #7
this_me_
New Member
 
Join Date: Apr 2002
Location: this_me_
Posts: 1
Default

This does something similar. It changes the colour of the cell to Red, but it only does this for one cell.

If anyone know how to change this so that it does it for multiple cells along a row (say the first 10), I would like to know how to do that.

Thanks

Sub red()
'
' red Macro
' Keyboard Shortcut: Ctrl+r
'
Dim i As Integer
For i = 1 To 10

With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

Next i

End Sub
this_me_ is offline   Reply With Quote
Old Apr 12th, 2002, 07:31 AM   #8
GeorgeB
Board Regular
 
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
Default

Try the format painter (the little paintbrush) Just put the cellpointer on the cell with the format you want and double click on the paintbrush. Any cell you then click on will duplicate the format in the original cell. Click Esc to abort.
This will work for multiple cells also. Just highlight the row you want.
Good luck
__________________
George

Learn to listen. Opportunity sometimes knocks very softly.
GeorgeB is offline   Reply With Quote
Old Apr 12th, 2002, 07:46 AM   #9
jimboy
Board Regular
 
Join Date: Apr 2002
Posts: 2,314
Default

Not sure if I have read it wrong, or if everyone has else has, but try this;

Sub Make_a_j_bold ()

ActiveCell.Range("A1:J1").Select
Selection.Font.Bold = True
Selection.End(xlToLeft).Select

End Sub
jimboy 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 09:50 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