I want to make a custome borders icon to use on the tool bar. I need a
double line at the top and a single line at the bottom. PLease help, Robin
I want to make a custome borders icon to use on the tool bar. I need a
double line at the top and a single line at the bottom. PLease help, Robin
First, open the VBA editor (ALT+F11) and create a new module in your VBA project (select your workbook's name in the left pane and click Insert>Module on the menu). Double click the module to open it in the right pane. Paste this code in the new module:
Sub borders()
'
' borders Macro
' Selection.borders(xlDiagonalDown).LineStyle = xlNone
Selection.borders(xlDiagonalUp).LineStyle = xlNone
Selection.borders(xlEdgeLeft).LineStyle = xlNone
With Selection.borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.borders(xlEdgeRight).LineStyle = xlNone
End Sub
Exit the VBA editor (ALT-Q)
To create a new icon for a toolbar button, right click anywhere on any toolbar and select "Customize..."
On the "Commands" tab, select Tools in the left pane and scroll in the right pane to an icon named Custom. Drag this icon to your desired location on your toolbar.
Right click on this new icon and select either "Edit button image" or "Select button image" and create the look you want.
Then, right click on your new design and select "Assign Macro..." and select "borders" from the list of available macros and click OK.
Finally, click "Close" on the Customize box. Select your desired cell and click your new tool bar button. Remember, the top border of one cell is the same as the bottom border of the cell above it.
Good Luck
Bruce
The older I get, the better I used to be.
USA
robin
This is the code I got when I recorded a macro while formatting as you
describe.
Copy/paste to a general module in your workbook. For instructions on creating
a general module see below.
Assign it to a button on your Toolbar.
Sub Macro2()
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
To get a button to the Toolbar you can.........
Tools>Customize>Commands>Macros.
Drag the smiley-face to the Toolbar.
Right-click on it a Assign Macro and also "Change Button Image" if you wish.
OK your way out.
If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".
http://www.mvps.org/dmcritchie/excel/getstarted.htm
In the meantime..........
First...create a backup copy of your original workbook.
To create a General Module, hit ALT + F11 to open the Visual Basic Editor.
Hit CRTL + R to open Project Explorer.
Find your workbook/project and select it.
Right-click and Insert>Module. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.
Gord Dibben Excel MVP
On Thu, 3 Feb 2005 10:09:02 -0800, "robin" <robin@discussions.microsoft.com>
wrote:
>I want to make a custome borders icon to use on the tool bar. I need a
>double line at the top and a single line at the bottom. PLease help, Robin
Thank you,
It works, the only thing is, it does not allow me to undo it without
clearing the borders using the clear borders button. Is there an additional
command I can put into the macros to allow the undo feature to work?
Thanks, Robin
"Gord Dibben" wrote:
> robin
>
> This is the code I got when I recorded a macro while formatting as you
> describe.
>
> Copy/paste to a general module in your workbook. For instructions on creating
> a general module see below.
>
> Assign it to a button on your Toolbar.
>
> Sub Macro2()
> With Selection.Borders(xlEdgeTop)
> .LineStyle = xlDouble
> .Weight = xlThick
> .ColorIndex = xlAutomatic
> End With
> With Selection.Borders(xlEdgeBottom)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> End Sub
>
> To get a button to the Toolbar you can.........
>
> Tools>Customize>Commands>Macros.
>
> Drag the smiley-face to the Toolbar.
>
> Right-click on it a Assign Macro and also "Change Button Image" if you wish.
>
> OK your way out.
>
> If not familiar with VBA and macros, see David McRitchie's site for more on
> "getting started".
>
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
> In the meantime..........
>
> First...create a backup copy of your original workbook.
>
> To create a General Module, hit ALT + F11 to open the Visual Basic Editor.
>
> Hit CRTL + R to open Project Explorer.
>
> Find your workbook/project and select it.
>
> Right-click and Insert>Module. Paste the code in there. Save the
> workbook and hit ALT + Q to return to your workbook.
>
>
> Gord Dibben Excel MVP
>
> On Thu, 3 Feb 2005 10:09:02 -0800, "robin" <robin@discussions.microsoft.com>
> wrote:
>
> >I want to make a custome borders icon to use on the tool bar. I need a
> >double line at the top and a single line at the bottom. PLease help, Robin
>
>
robin
For sample "Undo" code see John Walkenbach's site.
http://www.j-walk.com/ss/excel/tips/tip23.htm
Gord
On Thu, 10 Feb 2005 11:15:02 -0800, "robin" <robin@discussions.microsoft.com>
wrote:
>Thank you,
>It works, the only thing is, it does not allow me to undo it without
>clearing the borders using the clear borders button. Is there an additional
>command I can put into the macros to allow the undo feature to work?
>Thanks, Robin
>
>"Gord Dibben" wrote:
>
>> robin
>>
>> This is the code I got when I recorded a macro while formatting as you
>> describe.
>>
>> Copy/paste to a general module in your workbook. For instructions on creating
>> a general module see below.
>>
>> Assign it to a button on your Toolbar.
>>
>> Sub Macro2()
>> With Selection.Borders(xlEdgeTop)
>> .LineStyle = xlDouble
>> .Weight = xlThick
>> .ColorIndex = xlAutomatic
>> End With
>> With Selection.Borders(xlEdgeBottom)
>> .LineStyle = xlContinuous
>> .Weight = xlThin
>> .ColorIndex = xlAutomatic
>> End With
>> End Sub
>>
>> To get a button to the Toolbar you can.........
>>
>> Tools>Customize>Commands>Macros.
>>
>> Drag the smiley-face to the Toolbar.
>>
>> Right-click on it a Assign Macro and also "Change Button Image" if you wish.
>>
>> OK your way out.
>>
>> If not familiar with VBA and macros, see David McRitchie's site for more on
>> "getting started".
>>
>> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>>
>> In the meantime..........
>>
>> First...create a backup copy of your original workbook.
>>
>> To create a General Module, hit ALT + F11 to open the Visual Basic Editor.
>>
>> Hit CRTL + R to open Project Explorer.
>>
>> Find your workbook/project and select it.
>>
>> Right-click and Insert>Module. Paste the code in there. Save the
>> workbook and hit ALT + Q to return to your workbook.
>>
>>
>> Gord Dibben Excel MVP
>>
>> On Thu, 3 Feb 2005 10:09:02 -0800, "robin" <robin@discussions.microsoft.com>
>> wrote:
>>
>> >I want to make a custome borders icon to use on the tool bar. I need a
>> >double line at the top and a single line at the bottom. PLease help, Robin
>>
>>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks