![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Australia
Posts: 186
|
Is there a quick way to set a border around every cell in a range?
I have a macro that is producing various data onto a number of worksheets. All the cells should have a border around them. I know I can use something like ActiveCell.BorderAround Weight:=xlMedium, ColorIndex:=xlAutomatic for each cell but this seems long and laborious. Is there some kind of for each loop such as - for each cell in a selected range set BorderAround. Alternatively is there a way to select a range and then withoe command format all the cells with border around? Any advice is greatly appreciated |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Sydney/Brisbane , Australia
Posts: 539
|
i got the following macro. this deals with a range already selected... and sets the border for each cell.
dont know if it helps you. Sub borderit() Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Posts: 363
|
Try:
For each cell in selection cell.BorderAround Weight:=xlMedium Next
__________________
It's never too late to learn something new. Ricky |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: Australia
Posts: 186
|
Thanks guys that has helped a lot.
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: Sydney/Brisbane , Australia
Posts: 539
|
Ricky...
you killed me there... I owe you a beer!
__________________
Colin |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|