There are several ways of doing this, "using a macro in different sheets" - u can assign macro to a shortcut, add as a button to the toolbar etc., Check the below article, it will explain you how to assign macros to shortcut keys, buttons and objects. http://funwithexcel.blogspot.com/2009/05/macro-basics-assigning-macros-to.html
Hope this is helpful. On Wed, May 20, 2009 at 6:36 AM, Aindril De <aind...@gmail.com> wrote: > Dear OldRider, > > You can record a blank macro and paste the code there. > > Or you can go to VB editor and insert a module there. Then you can use the > code. > > for Example: > > Sub ColorRow() > ActiveCell.EntireRow.Interior.Color = RGB(255, 255, 160) > ActiveCell.EntireRow.Font.Bold = True > ' Check for first execution of the macro and set row > ' value if it is: > If x = Empty Then > x = ActiveCell.Row > ' Set previous row property back > ElseIf Not x = ActiveCell.Row Then > Rows(x).EntireRow.Interior.Color = RGB(255, 255, 255) > If x > 1 Then Rows(x).EntireRow.Font.Bold = False > Rows(x).EntireRow.Interior.Pattern = -4142 > End If > ' Capture new row value for comparison against next selection. > x = ActiveCell.Row > End Sub > > Then if you try to add a macro button to the tool bar or whereever you > want, You will find a macro named "ColorRow" for the example given above. > > This will enable you to use the macro for all the worksheets. > > Please let me know if this helps. > > Regards, > Andy > > > > On Wed, May 20, 2009 at 5:37 PM, OldRider <sowhat...@gmail.com> wrote: > >> >> Folks: G'day. I am an absolute novice at VBA and macros. I do get >> around by adapting solutions provided by more knowledgeable and >> learned people. So please be understanding. >> >> This is the issue I am trying to resolve. I need to highlight the >> current row I am using and I have the perfect code to use. >> >> The catch is that I would like to have it as a button (little smiley >> face) on the toolbar so that I can use it on any spreadsheet I am >> creating/using. I do not intend to distribute the code. >> >> I have found the perfect code - Thanks to David McRitchie. (http:// >> www.mvps.org/dmcritchie/excel/event.htm) This is the code I used: >> >> Private Sub Worksheet_SelectionChange(ByVal Target As Range) >> Cells.Interior.colorindex = 0 'Turn off previous use >> If Cells(1, 1) = "." Then Exit Sub >> Target.EntireRow.Interior.colorindex = 38 >> End Sub >> >> However as this code is limited to the sheet in which the code is >> placed, I then adapted it so that it is available on all worksheets in >> a workbook. Thanks to Damon Ostrander.(http://www.mrexcel.com/archive/ >> VBA/29582.html <http://www.mrexcel.com/archive/VBA/29582.html>) >> >> I pasted a WorkbookSheetSelectionChange event in the ThisWorkbook >> event code pane and the code now works perfectly on all worksheets in >> a workbook. >> >> But I have to paste it to every workbook that I need to use the code >> in. >> >> With my limited knowledge, I then tried to turn it into an add-in >> ( .xla file) following instructions I found on the net >> 1.Insert Module >> 2. Pasted unchanged code into module >> 3. ALT-Q to return to sheet and saved as .xla files >> 4. Restarted Excel and ticked the add-in under Tools. >> 5. Tried to customise button - Toolbars - customise - command-macro- >> moved Smiley face to toolbar - Assign macro.........No macro available >> >> Please help!!! I am not competent enough to build a toolbar or write >> additional code to create a button. >> >> I would like to be able to use this code at my discretion on any >> spreadsheet without having to paste the code every time into the >> current spreadsheet. >> >> Thanks in advance and God bless, OR >> >> >> >> >> >> >> >> >> >> >> >> >> > > > > -- http://funwithexcel.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---