problem with leading 0's

mikeellinas

New Member
Joined
Nov 7, 2017
Messages
25
I have a macro that imports data from an outside workbook to the active workbook. A problem I am having is that some of the numbers have leading zeroes, then they do not come over. Example: if the number is 099999999, it shows up on the new sheet as 99999999. Any ideas how I can get the leading zero to show up when importing? Added note, sometimes there may be more than one leading zero.

Here is my code:

For lngTranIndex = LBound(arrTranType) To UBound(arrTranType)

Sheets(strSpecifications).Range("G" & lngLastRowSpecSht + lngTranIndex).Value = _
Sheets(strTestFile).Range("J" & i).Value
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try declaring arrTranType() as String. As a string, it will maintain the leading zero(s), as a number, it will drop them.
 
Upvote 0

Forum statistics

Threads
1,226,735
Messages
6,192,733
Members
453,752
Latest member
Austin2222

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
Back
Top