Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
number format in regional setting vista not carried in excel2007 | Excel Discussion (Misc queries) | |||
'conditional format' cells for the highest number in a range | Excel Discussion (Misc queries) | |||
Setting Cell Number Format With A Worksheet Function | Excel Worksheet Functions | |||
how to format only a specific character or number in each cell withina range of cells | Excel Worksheet Functions | |||
Setting range of cells format to currency | Excel Programming |