Lord And Savior
Lord And Savior

Reputation: 11

VBA Retaining Leading Zeros

I have an issue with retaining leading zeros in my document.

First of all I use Vlookup as below:

    aba = Application.VLookup("Routing/ABA/Sort Code:", Sheets("temp").Range("A1:B20"), 2, 0)

Then I need to put results into another sheet:

    Sheets("List").Range("B35") = aba

However even though the ABA code in the temp sheet is for example "0001", the destination sheet shows it as "1". I've seen some attempts in setting up custom number format, however numbers of zeros might vary in my case and this way doesn't work.

Is there a way to move the original number EXCATLY THE SAME to another sheet retaining all the leading zeros?

Thanks!

Upvotes: 0

Views: 1073

Answers (1)

TehSphinX
TehSphinX

Reputation: 7440

Format the cell as string/text, not number. You can do that programmatically by adding a leading ' sign to the value.

Sheets("List").Range("B35") = "'" & aba

Upvotes: 1

Related Questions