Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting number format on range of cells

I have the following VBScript function to set the NumberFormat on a Range.
It appears instead to be setting the NumberFormat for all cells in the Sheet.
Can anyone explain what I'm doing wrong? (Using Excell 2002)

Private Sub setCellRangeNumberFormat (intBeginRow, intBeginColumn,
intEndRow, intEndColumn, strNumberFormat)
m_objExcelApp.Range ( _
m_objExcelApp.Cells(intBeginRow, intBeginColumn), _
m_objExcelApp.Cells(intEndRow, intEndColumn) _
).Style.NumberFormat = strNumberFormat
End Sub

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting number format on range of cells

Depends on how you are calling this function (what arguments you are
supplying)...

"Neils Christoffersen" wrote:

I have the following VBScript function to set the NumberFormat on a Range.
It appears instead to be setting the NumberFormat for all cells in the Sheet.
Can anyone explain what I'm doing wrong? (Using Excell 2002)

Private Sub setCellRangeNumberFormat (intBeginRow, intBeginColumn,
intEndRow, intEndColumn, strNumberFormat)
m_objExcelApp.Range ( _
m_objExcelApp.Cells(intBeginRow, intBeginColumn), _
m_objExcelApp.Cells(intEndRow, intEndColumn) _
).Style.NumberFormat = strNumberFormat
End Sub

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Setting number format on range of cells

What you are doing is setting the Style number format, not the Cell number
format.

By default, all the cells in the workbook will have the Normal style. By
changing the Normal style, you affect all the cells in the workbook.

Remove the .Style from your code and you will be setting the cell formats.

By the way, your code depends on the worksheet you are changing being
active. If you want to have it work on other sheets, you would need to
qualify the Range reference and each Cells reference with the name of the
worksheet (and the workbook if the workbook is not selected). Thecode is
fine if it only works on an active sheet.

--
John Green
Sydney
Australia


"Neils Christoffersen" wrote
in message ...
I have the following VBScript function to set the NumberFormat on a Range.
It appears instead to be setting the NumberFormat for all cells in the

Sheet.
Can anyone explain what I'm doing wrong? (Using Excell 2002)

Private Sub setCellRangeNumberFormat (intBeginRow, intBeginColumn,
intEndRow, intEndColumn, strNumberFormat)
m_objExcelApp.Range ( _
m_objExcelApp.Cells(intBeginRow, intBeginColumn), _
m_objExcelApp.Cells(intEndRow, intEndColumn) _
).Style.NumberFormat = strNumberFormat
End Sub

Thanks!



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
number format in regional setting vista not carried in excel2007 bsm Excel Discussion (Misc queries) 1 March 2nd 10 09:21 AM
'conditional format' cells for the highest number in a range Browny Excel Discussion (Misc queries) 5 March 25th 08 07:31 AM
Setting Cell Number Format With A Worksheet Function [email protected] Excel Worksheet Functions 1 December 16th 05 07:37 PM
how to format only a specific character or number in each cell withina range of cells Colleen Excel Worksheet Functions 1 September 12th 05 05:44 PM
Setting range of cells format to currency Radek Michalski Excel Programming 1 December 20th 03 11:15 PM


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