Typecast

priya_anthony

Board Regular
Joined
Jul 17, 2007
Messages
64
Hi experts
Need your help
What am i looking out is to type cast the data i.e numeric to string
i.e i retrieve the data as "001" from the database which is numeric and when i type cast it to a string it gives only 1
i.e
Str(oPersonHelp.Value(R, C)---'it contains the value 001)
i want the same data i.e 001 instead of 1

kindly help
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
The numeric data is not 001 - it is just formatted to look that way.
So you need to format the string the way you want with something like :-

Code:
Dim MyText as string
MyText = Format(oPersonHelp.Cells(R, C).Value,"000")
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
Use Text instead of Value.

That will return the value as it is formatted, if that's what you want.:)
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,316
Members
414,053
Latest member
Dual Showman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top