ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For net borders (https://www.excelbanter.com/excel-programming/423967-net-borders.html)

Faboboren

For net borders
 
Hi,

I want to write a border only around A7:C11 and A12:C16 (in different
sheets), not in rows in between. I wrote down this code and I am getting
lines at every row..any idea how I should change that? Thanks

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
With sht.Range("A12:C16")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
Next sht
End Sub


Nigel[_2_]

For net borders
 
Add the following two lines to the setting for the range(s)

.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone

--

Regards,
Nigel




"Faboboren" wrote in message
...
Hi,

I want to write a border only around A7:C11 and A12:C16 (in different
sheets), not in rows in between. I wrote down this code and I am getting
lines at every row..any idea how I should change that? Thanks

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
With sht.Range("A12:C16")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
Next sht
End Sub



Chip Pearson

For net borders
 

You can use the BorderAround method to create a border around a range
of cells. E.g.,

Worksheets("Sheet1").Range("A7:C11").BorderAround _
LineStyle:=xlSolid, Weight:=xlMedium, ColorIndex:=xlAutomatic
Worksheets("Sheet2").Range("A12:C16").BorderAround _
LineStyle:=xlSolid, Weight:=xlMedium, ColorIndex:=xlAutomatic


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 12 Feb 2009 06:29:11 -0800, Faboboren
wrote:

Hi,

I want to write a border only around A7:C11 and A12:C16 (in different
sheets), not in rows in between. I wrote down this code and I am getting
lines at every row..any idea how I should change that? Thanks

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
With sht.Range("A12:C16")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
Next sht
End Sub


Faboboren

For net borders
 
Thanks Nigel,

I am still getting borders at any single row, can you show me exactly where
I should insert those 2 lines?

"Nigel" wrote:

Add the following two lines to the setting for the range(s)

.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone

--

Regards,
Nigel




"Faboboren" wrote in message
...
Hi,

I want to write a border only around A7:C11 and A12:C16 (in different
sheets), not in rows in between. I wrote down this code and I am getting
lines at every row..any idea how I should change that? Thanks

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
With sht.Range("A12:C16")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
Next sht
End Sub




Faboboren

For net borders
 
Perfect, Thanks

"Chip Pearson" wrote:


You can use the BorderAround method to create a border around a range
of cells. E.g.,

Worksheets("Sheet1").Range("A7:C11").BorderAround _
LineStyle:=xlSolid, Weight:=xlMedium, ColorIndex:=xlAutomatic
Worksheets("Sheet2").Range("A12:C16").BorderAround _
LineStyle:=xlSolid, Weight:=xlMedium, ColorIndex:=xlAutomatic


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 12 Feb 2009 06:29:11 -0800, Faboboren
wrote:

Hi,

I want to write a border only around A7:C11 and A12:C16 (in different
sheets), not in rows in between. I wrote down this code and I am getting
lines at every row..any idea how I should change that? Thanks

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
With sht.Range("A12:C16")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
Next sht
End Sub



Faboboren

For net borders
 
Chip,

How I avoid to run the macros in my Macro sheet called Macros with these 4
lines?...

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")

"Chip Pearson" wrote:


You can use the BorderAround method to create a border around a range
of cells. E.g.,

Worksheets("Sheet1").Range("A7:C11").BorderAround _
LineStyle:=xlSolid, Weight:=xlMedium, ColorIndex:=xlAutomatic
Worksheets("Sheet2").Range("A12:C16").BorderAround _
LineStyle:=xlSolid, Weight:=xlMedium, ColorIndex:=xlAutomatic


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 12 Feb 2009 06:29:11 -0800, Faboboren
wrote:

Hi,

I want to write a border only around A7:C11 and A12:C16 (in different
sheets), not in rows in between. I wrote down this code and I am getting
lines at every row..any idea how I should change that? Thanks

Sub Set_Borders()
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.Range("A7:C11")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
With sht.Range("A12:C16")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders.Weight = xlMedium
.Borders.ColorIndex = xlAutomatic
End With
Next sht
End Sub




All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com