Leading zero - Missing

CarlStephens

Board Regular
Joined
Sep 25, 2020
Messages
128
Office Version
  1. 2016
Platform
  1. Windows
Hello All,

I have a excel doc on One Drive that is shared for multiple users, and the below code basically creates a folder in a location referencing a concatenated cell, per the below:
C:\Users\8448\Desktop\Candidates\Hotel_Svc\

The spreadsheet knows on whose PC to set the folder up based on the windows user ID that is saved in the spreadsheet, which on the above is 08448.

Now, the interesting part.......if the users ID begins with a letter or an number other than zero, all is good and the code works, however, I have a user whose user windows user ID is 08448 and for the life of me I cannot keep the leading zero in the cell. where the user ID is stored. I have tried =TEXT, =CONCATENATE, CUSTOM 00000, and nothing is working.....in short, I need the cell to be in number format and show the 0. Any ideas on this? Thank you.

Sub NewFolder()
'
If Len(Dir([B3] & [M1], vbDirectory)) = 0 Then
MkDir [B3] & [M1]
MsgBox "Folder created in location"
Else
MsgBox "Folder already exists!"
End If
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You can have a number 8448 in the cell & use a custom format to make it look like 08448, or if yo need it to be 08448 then it needs to be text.
 
Upvote 0
Oddly enough, it does not work still.....I have tried EVERYTHING. Thank you anyway for your response and your time, it is appreciated.
 
Upvote 0
What exactly is in B3 & M1, and in what way doesn't it work?
 
Upvote 0
M1 is referencing a name of the folder, and B3 is the path.

It is definitely related to the 0 issue, as all other users Windows ID does not start with a 0 and we do not have this problem.
 
Upvote 0
If B3 is C:\Users\8448\Desktop\Candidates\Hotel_Svc\ then it's text, so you should be able to just add the leading 0
 
Upvote 0
I have tried TEXT, CONCATENATE, CUSTOM, =TEXT, SPECIAL FORMATTING.....all of them do not work.
 
Upvote 0
Is B3 just text, or is it a formula?
 
Upvote 0

Forum statistics

Threads
1,214,785
Messages
6,121,543
Members
449,038
Latest member
Guest1337

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