Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Making a number have Text format

Hi Howard,

Don't see the original post :-(

Do you mean something like:

Sub b()
Dim s As String

s = Format$(1.2345, "$0.000")
Debug.Print s
End Sub

or

Sub c()
Dim s As String

s = Format$(1234568, "00-00-00-00")
Debug.Print s
End Sub

Perhaps I'm missing something. As I say I can't see your original post.

Regards,

Peter Beach

"Howard Kaikow" wrote in message
...
It's been a while, so I guess there's no solution.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Making a number have Text format

"Peter Beach" wrote in message
...
Hi Howard,

Don't see the original post :-(

Do you mean something like:

Sub b()
Dim s As String

s = Format$(1.2345, "$0.000")
Debug.Print s
End Sub

or

Sub c()
Dim s As String

s = Format$(1234568, "00-00-00-00")
Debug.Print s
End Sub

Perhaps I'm missing something. As I say I can't see your original post.



The following is the original post.
---------------------------
I am inserting stuff into some cells as follows:

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

Then, I change the cells in columns 2-5 to numeric formattrying to change
some of the cells to numeric format. using code like

With shtExcel.Range(Cells(lngFormat, 2),Cells(lngFormat + lngHigh, 3))
.Value = .Value
End With

Then assigning the relevant format for the cells in eaxh column.

However, the cells in column 1 are supposed to retain Text format, but some
cells have all numbers, e.g., 000, and are intended to stay as Text.

If I set Application.ErrorCheckingOptions.NumberAsText = false, I achieve my
goal while the workbook is open.
However, if I save the workbook, exit Excel, then re-open the workbook, the
NumberAsText propety reverts to whatever the user has chosen.

How can I programmatically change numbers to Text format?
If I save the value in a string variable, then assign to the Value property,
the cell is treated as a number, e.g., 000 becomes 0.

Is there a way to do the deed without changing a user's NumberAsText
property?

------------------------------
And I followed this with the following post:
------------------------------------------
I tried

.Range(Cells(lngFormat, 1), Cells(lngFormat + lngHigh,
1)).NumberFormat = "@"
For i = 0 To lngHigh
With Cells(lngFormat + i, 1)
If IsNumeric(.Value) Then
strTemp = CStr(.Value)
.Value = "'" & strTemp
End If
End With
Next i

Excel still insists on marking the cells as errors.

The only real issue is how to programmatically tell Excel to ignore the
"error" for those cells.
Is there a way to do that?

The NumberAsText property can be overridden by the user's options, not to
mention the property is not supported by Excel 97 and 2000.


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
Making the text in a cell with a money format centered Wombat Excel Discussion (Misc queries) 6 April 22nd 23 12:12 AM
Convert numbers from text format to number format merlin68 Excel Discussion (Misc queries) 7 June 20th 07 07:03 PM
Change number (in text format) to numeric format Pam Excel Discussion (Misc queries) 5 October 24th 05 07:45 PM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
making a number be text Fredrated Excel Worksheet Functions 2 June 1st 05 02:37 AM


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