ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formating cells (https://www.excelbanter.com/excel-programming/377904-formating-cells.html)

Patrick Simonds

Formating cells
 
I need a piece of code to insert into a routine. What I need is for the code
to place a boarder around each cell (column A through T) of the current row.
The curser will not always be in the same cell when the code is run.



Gary Keramidas[_2_]

Formating cells
 
you can give this a try

Sub test()
Dim currow As Long
currow = ActiveCell.Row

With Range("A" & currow & ":T" & currow).Borders(xlEdgeBottom)
.Weight = xlThin
End With

With Range("A" & currow & ":T" & currow).Borders(xlEdgeTop)
.Weight = xlThin
End With

With Range("A" & currow & ":T" & currow).Borders(xlEdgeRight)
.Weight = xlThin
End With

With Range("A" & currow & ":T" & currow).Borders(xlEdgeLeft)
.Weight = xlThin
End With

With Range("A" & currow & ":T" & currow).Borders(xlInsideVertical)
.Weight = xlThin
End With
End Sub


--


Gary


"Patrick Simonds" wrote in message
...
I need a piece of code to insert into a routine. What I need is for the
code to place a boarder around each cell (column A through T) of the
current row. The curser will not always be in the same cell when the code
is run.



Greg Glynn

Formating cells
 

Patrick Simonds wrote:
I need a piece of code to insert into a routine. What I need is for the code
to place a boarder around each cell (column A through T) of the current row.
The curser will not always be in the same cell when the code is run.


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 22/11/2006 by Greg Glynn
'
For x = 1 To 20
Cells(ActiveCell.Row, x).Select
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
Next x
End Sub



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

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