Swaminathan_K
asked on
Excel 2007
Hi,
Iam written a macro to do the below formattinf for a range of cells. Right now I have around 900 rows of data , the below code executes slowly , it takes around 7-9 mins , Can any one suggest an alternative and fine tuning for the below code
'format cell borders
Range("A23:O" & LastDetailRow - 1).Select
Selection.RowHeight = 12.75
Selection.Borders(xlDiagon alDown).Li neStyle = xlNone
Selection.Borders(xlDiagon alUp).Line Style = xlNone
With Selection.Borders(xlEdgeLe ft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTo p)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBo ttom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRi ght)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInside Vertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInside Horizontal )
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' left justify cell
Range("A23:A" & LastDetailRow - 1).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
' left justify Activation Date
Range("F23:F" & LastDetailRow - 1).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.NumberFormat = "mm/dd/yy"
Iam written a macro to do the below formattinf for a range of cells. Right now I have around 900 rows of data , the below code executes slowly , it takes around 7-9 mins , Can any one suggest an alternative and fine tuning for the below code
'format cell borders
Range("A23:O" & LastDetailRow - 1).Select
Selection.RowHeight = 12.75
Selection.Borders(xlDiagon
Selection.Borders(xlDiagon
With Selection.Borders(xlEdgeLe
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTo
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBo
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRi
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInside
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInside
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' left justify cell
Range("A23:A" & LastDetailRow - 1).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
' left justify Activation Date
Range("F23:F" & LastDetailRow - 1).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.NumberFormat = "mm/dd/yy"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER