ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   data format 99 (https://www.excelbanter.com/excel-programming/361823-data-format-99-a.html)

RaY

data format 99
 
I am using the following array to obtain data from a worksheet:
zs_subldeger = (Range(Cells(row_set, 1), Cells(lastrow, 1)))
The value of the cell is 0001 however the data is read as a numeric value
of 1?
How do I retain the text value 001?

When I Dim zs_subldeger as string I get a type mismatch error .

Thanks

--
Ray

witek

data format 99
 
Ray wrote:
I am using the following array to obtain data from a worksheet:
zs_subldeger = (Range(Cells(row_set, 1), Cells(lastrow, 1)))
The value of the cell is 0001 however the data is read as a numeric value
of 1?
How do I retain the text value 001?

When I Dim zs_subldeger as string I get a type mismatch error .

Thanks


dim zs_subldeger as string
zs_subldeger = Format$((Range(Cells(row_set, 1), Cells(lastrow, 1))),"000")


Is it what you need?

witek

data format 99
 
witek wrote:
Ray wrote:

I am using the following array to obtain data from a worksheet:
zs_subldeger = (Range(Cells(row_set, 1), Cells(lastrow, 1)))
The value of the cell is 0001 however the data is read as a numeric
value of 1?
How do I retain the text value 001?

When I Dim zs_subldeger as string I get a type mismatch error .

Thanks


dim zs_subldeger as string
zs_subldeger = Format$((Range(Cells(row_set, 1), Cells(lastrow, 1))),"000")


Is it what you need?


or even better

zs_subldeger = Format$((Range(Cells(row_set, 1), Cells(lastrow,
1))),Range(Cells(row_set, 1), Cells(lastrow, 1)).NumberFormat)


All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com