Using the Macro Recorder:
Sub Macro2()
Range("G1").Select
Selection.NumberFormat = "$#,##0.00"
Range("G2").Select
Selection.NumberFormat = "0.00%"
Range("G1:G2").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
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End Sub
--
Gary's Student
"Michael" wrote:
Hey Guys.
I was wondering if someone could help me.
I am writing VB code for a budgetary and forecasting tool. I have the code
written to do the analysis, and then create a summary table with all the
information in it. However, the cells are formatted correctly so each time I
run it, I have make some cosmetic changes. I know you can do this using VB,
but I do not know how.
I need to:
- Change the format of a range from a number to currency.
- Change the format of a range from a number to a percentage.
- Add all around borders for a range.
I greatly appreciate any assistance you could provide.
Thanks,
-Michael