ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need the original digit format with zeroes untrimmed (https://www.excelbanter.com/excel-programming/314625-i-need-original-digit-format-zeroes-untrimmed.html)

alfonso gonzales

I need the original digit format with zeroes untrimmed
 
Hello,
My query is about how to retain an 8 digit format while copying data values
from one file to another.
I have a dbf file with one column containing 8 digit indexes. When I copy
some of those into an excelworksheet I get some of the indexes that start
with the zero trimmed, eg. 7063004 instead of 07063004. Now, it is
important that the indexes I copy are displayed and operated on as 8-digit
values (including the initial zeroes). How can I do that?

My macro does the following instruction
Dim IndeksVal As Long ' (I have also tried String) - this is a temporary
value
'[....]
IndeksVal = DbfData.Worksheets(1).Cells(oCell.Row, 1).Value
Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value =
IndeksVal

and the following direct assignent does not work either:
'[....]

Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value =
DbfData.Worksheets(1).Cells(oCell.Row, 1).Value


Other values that do not start with the zero, get copied "correctly".


Alvaro E. Gonzales



Frank Kabel

I need the original digit format with zeroes untrimmed
 
Hi
try setting the format of these cell to 'Text' before copying the values.

Also try to use the .formula property

"alfonso gonzales" wrote:

Hello,
My query is about how to retain an 8 digit format while copying data values
from one file to another.
I have a dbf file with one column containing 8 digit indexes. When I copy
some of those into an excelworksheet I get some of the indexes that start
with the zero trimmed, eg. 7063004 instead of 07063004. Now, it is
important that the indexes I copy are displayed and operated on as 8-digit
values (including the initial zeroes). How can I do that?

My macro does the following instruction
Dim IndeksVal As Long ' (I have also tried String) - this is a temporary
value
'[....]
IndeksVal = DbfData.Worksheets(1).Cells(oCell.Row, 1).Value
Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value =
IndeksVal

and the following direct assignent does not work either:
'[....]

Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value =
DbfData.Worksheets(1).Cells(oCell.Row, 1).Value


Other values that do not start with the zero, get copied "correctly".


Alvaro E. Gonzales




Ron Rosenfeld

I need the original digit format with zeroes untrimmed
 
On Mon, 25 Oct 2004 17:27:22 +0200, "alfonso gonzales"
wrote:

Hello,
My query is about how to retain an 8 digit format while copying data values
from one file to another.
I have a dbf file with one column containing 8 digit indexes. When I copy
some of those into an excelworksheet I get some of the indexes that start
with the zero trimmed, eg. 7063004 instead of 07063004. Now, it is
important that the indexes I copy are displayed and operated on as 8-digit
values (including the initial zeroes). How can I do that?


In order to ensure the leading zeros, I believe you need to treat the value as
a properly formatted string, or format the cell in which the index is displayed
as "00000000"

For example:

dim Indx as String
Indx = Format(num,"00000000")


--ron

alfonso gonzales

I need the original digit format with zeroes untrimmed
 
I omitted to mention an essential fact: the problem with formatting these
cells to "Text" before copying the values is that I open the source file
exclusively for reading, and must not introduce anychanges:
the file is used by another program.


Użytkownik "Frank Kabel" napisał w wiadomości
...
Hi
try setting the format of these cell to 'Text' before copying the values.

Also try to use the .formula property

"alfonso gonzales" wrote:

Hello,
My query is about how to retain an 8 digit format while copying data
values
from one file to another.
I have a dbf file with one column containing 8 digit indexes. When I copy
some of those into an excelworksheet I get some of the indexes that start
with the zero trimmed, eg. 7063004 instead of 07063004. Now, it is
important that the indexes I copy are displayed and operated on as
8-digit
values (including the initial zeroes). How can I do that?

My macro does the following instruction
Dim IndeksVal As Long ' (I have also tried String) - this is a temporary
value
'[....]
IndeksVal = DbfData.Worksheets(1).Cells(oCell.Row, 1).Value
Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value
=
IndeksVal

and the following direct assignent does not work either:
'[....]

Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value
=
DbfData.Worksheets(1).Cells(oCell.Row, 1).Value


Other values that do not start with the zero, get copied "correctly".


Alvaro E. Gonzales






alfonso gonzales

I need the original digit format with zeroes untrimmed
 
OK, I see it works when I format the target cells, so it is fine for me,
thank you.
Użytkownik "Frank Kabel" napisał w wiadomości
...
Hi
try setting the format of these cell to 'Text' before copying the values.

Also try to use the .formula property

"alfonso gonzales" wrote:

Hello,
My query is about how to retain an 8 digit format while copying data
values
from one file to another.
I have a dbf file with one column containing 8 digit indexes. When I copy
some of those into an excelworksheet I get some of the indexes that start
with the zero trimmed, eg. 7063004 instead of 07063004. Now, it is
important that the indexes I copy are displayed and operated on as
8-digit
values (including the initial zeroes). How can I do that?

My macro does the following instruction
Dim IndeksVal As Long ' (I have also tried String) - this is a temporary
value
'[....]
IndeksVal = DbfData.Worksheets(1).Cells(oCell.Row, 1).Value
Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value
=
IndeksVal

and the following direct assignent does not work either:
'[....]

Application.ThisWorkbook.Worksheets(1).Cells(posco unter, INDX).Value
=
DbfData.Worksheets(1).Cells(oCell.Row, 1).Value


Other values that do not start with the zero, get copied "correctly".


Alvaro E. Gonzales







All times are GMT +1. The time now is 05:56 AM.

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