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
Using the Macro Recorder:Sub Macro2()
Range(quot;G1quot;).Select
Selection.NumberFormat = quot;$#,##0.00quot;
Range(quot;G2quot;).Select
Selection.NumberFormat = quot;0.00%quot;Range(quot;G1:G2quot;).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 Studentquot;Michaelquot; wrote:
gt; Hey Guys.
gt;
gt; I was wondering if someone could help me.
gt;
gt; I am writing VB code for a budgetary and forecasting tool. I have the code
gt; written to do the analysis, and then create a summary table with all the
gt; information in it. However, the cells are formatted correctly so each time I
gt; run it, I have make some cosmetic changes. I know you can do this using VB,
gt; but I do not know how.
gt;
gt; I need to:
gt; - Change the format of a range from a number to currency.
gt; - Change the format of a range from a number to a percentage.
gt; - Add all around borders for a range.
gt;
gt; I greatly appreciate any assistance you could provide.
gt;
gt; Thanks,
gt;
gt; -Michael
- Apr 21 Sat 2007 20:36
Changin Cell Formats using VBA
close
全站熱搜
留言列表
發表留言