Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Changing Number Format

I am inserting stuff into some cells as follows:

shtExcel.Range(Cells(lngRow, 1), Cells(lngRow, 5)) = Split(strBuffer, vbTab)

Then, I am trying to change some of the cells to numeric format.
What do I need to use instead of the following?

shtExcel.Range(Cells(lngFormat, 2), Cells(lngFormat + lngHigh,
3)).NumberFormat = "#,##0.00"



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Changing Number Format

"Howard Kaikow" wrote in message
...
I am inserting stuff into some cells as follows:

shtExcel.Range(Cells(lngRow, 1), Cells(lngRow, 5)) = Split(strBuffer,

vbTab)

Then, I am trying to change some of the cells to numeric format.
What do I need to use instead of the following?

shtExcel.Range(Cells(lngFormat, 2), Cells(lngFormat + lngHigh,
3)).NumberFormat = "#,##0.00"



It seems that I need to do the equivalent of "Convert To Number", before
doing the formatting, but I have not yet found that in the Excel object
model.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Changing Number Format

Hey Howard, here's your answer.

Add code like the following before setting the format.

For Each rngCell In shtExcel.Range(Cells(lngFormat, 2),
Cells(lngFormat + lngHigh, 3))
rngCell.Value = rngCell.Value
Next rngCell

This converts the cells from text to numeric format.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Changing Number Format

Hi Howard,

no need to loop

With shtExcel.Range(Cells(lngRow, 1), Cells(lngRow, 5))
..Value = .Value
End With

In passing, if shtExcel does not refer to the active sheet you may also need
to qualify each "Cells" with shtExcel.

Regards,
Peter T

"Howard Kaikow" wrote in message
...
Hey Howard, here's your answer.

Add code like the following before setting the format.

For Each rngCell In shtExcel.Range(Cells(lngFormat, 2),
Cells(lngFormat + lngHigh, 3))
rngCell.Value = rngCell.Value
Next rngCell

This converts the cells from text to numeric format.




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
Changing the format of a phone number scr Excel Worksheet Functions 2 October 13th 08 12:22 AM
Changing Phone number format Noncentz303 Excel Worksheet Functions 2 May 2nd 07 05:42 PM
Changing number format gcotterl Excel Worksheet Functions 0 July 17th 06 08:50 AM
Changing format of number without changing the value sweetsue516 Excel Discussion (Misc queries) 2 August 22nd 05 04:07 PM
Changing a cell's number format Chris Excel Programming 3 May 17th 05 08:31 PM


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

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

About Us

"It's about Microsoft Excel"