Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Setting borders with a macro

Hi

I recorded the below macro to set borders for each cell in a range. I just
think this macro could be shorter. I tried a few options buy they didn't
work. Could anyone help me to make it shorter.

Selection.CurrentRegion.Select


With Selection.borders(xlEdgeLeft)
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeTop)
.Weight = xlThin
.ColorIndex = xlAutomatic

End With
With Selection.borders(xlEdgeBottom)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeRight)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideVertical)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideHorizontal)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Thanks,

Orquidea
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Setting borders with a macro

You could use just this one line for the whole thing...

Selection.Borders.Weight = xlThin

--
HTH...

Jim Thomlinson


"orquidea" wrote:

Hi

I recorded the below macro to set borders for each cell in a range. I just
think this macro could be shorter. I tried a few options buy they didn't
work. Could anyone help me to make it shorter.

Selection.CurrentRegion.Select


With Selection.borders(xlEdgeLeft)
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeTop)
.Weight = xlThin
.ColorIndex = xlAutomatic

End With
With Selection.borders(xlEdgeBottom)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeRight)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideVertical)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideHorizontal)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Thanks,

Orquidea

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Setting borders with a macro

Thanks for your help

"Jim Thomlinson" wrote:

You could use just this one line for the whole thing...

Selection.Borders.Weight = xlThin

--
HTH...

Jim Thomlinson


"orquidea" wrote:

Hi

I recorded the below macro to set borders for each cell in a range. I just
think this macro could be shorter. I tried a few options buy they didn't
work. Could anyone help me to make it shorter.

Selection.CurrentRegion.Select


With Selection.borders(xlEdgeLeft)
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeTop)
.Weight = xlThin
.ColorIndex = xlAutomatic

End With
With Selection.borders(xlEdgeBottom)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeRight)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideVertical)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideHorizontal)

.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Thanks,

Orquidea

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro not able to run due to a security setting Wes Excel Discussion (Misc queries) 1 February 20th 07 09:58 PM
Setting up Macro to create pie chart. Hamish Charts and Charting in Excel 2 August 8th 06 02:30 PM
Setting up a Macro Nabeel Excel Worksheet Functions 2 February 25th 06 08:22 PM
Setting borders for two rows and all columns on spread sheet R OLEJAR Excel Worksheet Functions 0 February 1st 06 04:19 PM
Setting up a macro to print? Abi Excel Worksheet Functions 0 January 10th 05 08:09 PM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"