Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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
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
format cells depending on value range gashman Excel Discussion (Misc queries) 5 May 25th 10 04:10 PM
Conditional Format Range of Cells tommcbrny Excel Discussion (Misc queries) 4 November 5th 09 04:17 PM
Can't format cells in data range CLR Excel Discussion (Misc queries) 2 June 17th 09 02:31 PM
format cells range diacci1st Excel Discussion (Misc queries) 9 October 1st 08 12:03 AM
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM


All times are GMT +1. The time now is 12:42 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"