Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to format a range of cells from VB
I am new to Visual Basic for please forgive the "rookie" question.
I have a range of cells in an Excel spreadsheet that I need to format from a Visual Basic program. Can someone provide a brief example of how to do this? Or point me to some online documentation that would help? Thanks in advance. Wayne |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to format a range of cells from VB
Selection.NumberFormat = "#,##0.00"
or Range("A1:E3").NumberFormat = "$#,##0" for example... Is this what you're looking for? "Wayne Ware" wrote in message ... I am new to Visual Basic for please forgive the "rookie" question. I have a range of cells in an Excel spreadsheet that I need to format from a Visual Basic program. Can someone provide a brief example of how to do this? Or point me to some online documentation that would help? Thanks in advance. Wayne |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to format a range of cells from VB
Hi Wayne
Here are some examples of formatting through VBA. You don't necessarily have to select cells first before formatting them. I learnt how to format by recording macros and then studying the code. Macro1 below is an exmple of this. HTH Andrew B Cells are formatted without selection here. ActiveSheet.Range("D43:CH58") = "" ActiveSheet.Range("D43:CH58").Interior.ColorIndex = 15 A recorded macro. Sub Macro1() ' Range("B4:B19").Select With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With Columns("B:B").ColumnWidth = 10 With Selection.Interior .ColorIndex = 6 .Pattern = xlSolid End With Selection.NumberFormat = "0.0" Selection.Font.Bold = True End Sub Wayne Ware wrote: I am new to Visual Basic for please forgive the "rookie" question. I have a range of cells in an Excel spreadsheet that I need to format from a Visual Basic program. Can someone provide a brief example of how to do this? Or point me to some online documentation that would help? Thanks in advance. Wayne |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
format cells depending on value range | Excel Discussion (Misc queries) | |||
Conditional Format Range of Cells | Excel Discussion (Misc queries) | |||
Can't format cells in data range | Excel Discussion (Misc queries) | |||
format cells range | Excel Discussion (Misc queries) | |||
how do i format a cell based on format of a range of cells? | Excel Discussion (Misc queries) |