Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Michael
 
Posts: n/a
Default Changin Cell Formats using VBA

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Changin Cell Formats using VBA

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
Reveal cell formats and extendable range in tool/statusbar/icon. Danny O'Hern ([email protected]) Excel Worksheet Functions 0 April 29th 05 01:16 PM
Changing Cell formats to date fields automatically PCLIVE Excel Worksheet Functions 3 April 12th 05 10:34 PM
Can't open doc. Too many different cell formats. Steven Excel Discussion (Misc queries) 3 March 25th 05 07:56 PM
How do I find out how many different cell formats an existing wor. wheelsii Excel Discussion (Misc queries) 1 March 24th 05 04:58 PM


All times are GMT +1. The time now is 04:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"