PDA

View Full Version : Solved: Borders to all the used cells for all worksheets in a workbook



sindhuja
04-26-2012, 07:00 AM
I have a workbook with multiple sheets. I need to place border to all the worksheets from row 4. Can someone pls provide the coding to do so

i found coding only for the single sheet. I tried to edit but it didn’t work out for me.

-sindhuja

sindhuja
04-28-2012, 11:10 PM
can i get assistance on this pls..

Aussiebear
04-28-2012, 11:12 PM
Post what ever code you currently have, so we can assist you

sindhuja
04-29-2012, 02:45 AM
Hi,

I tried editing the code.. it works for me now :)



Sub Format()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws
MsgBox ws.Name
ws.Activate
Dim Cell As Range

For Each Cell In Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
If Left(Cell, 2) = " " Then Cell.ClearContents
Next Cell

With Cells.SpecialCells(xlCellTypeConstants, 23)
.BorderAround xlContinuous, xlThin, xlColorIndexAutomatic
On Error Resume Next 'used in case there are no inside borders
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End With
Next ws
End Sub

Aussiebear
04-29-2012, 05:02 AM
Then you should mark the thread as solved then!