How do I get the =LEFT function in excel, to also take the number zero as the first number?Need a formula that looks at the first digit or letter in a cellExcel Formula To Get First Non-Zero Value in Row and Return Column HeaderMS Excel: Count the max spaces between a number frequencyExcel Formula To Get LAST Non-Zero Value in Row and Return Column HeaderHow to find the first non-zero number from the bottom up by referenced vehicle#?How to select the first number in cell in Excel?Searching an array from bottom to topHow to get continuous number based on item number for each category in excel?Excel: lookup the last non-zero, non-empty cell in filtered range
Collect tracking code is not working properly
If Space Shuttle flies "like a brick", why does it need the wings?
Software for generating a lattice from a unit cell for molecular crystals?
Are humans superior to machines in chess?
How do you deal with someone who is nosy, projects their feelings about career, and gives unsolicited advice in that area?
Why did Magnus join Horus in his Heresy?
What's the most rewarding path?
Where and/or why is a slanted hyphen used?
What is the purpose of R1 in this circuit?
Driverless car Puzzle
Seven Pounds Eight and Eight Pence
I'm from Mumbai, India. I want to travel to Europe as a tourist but my salary is low ( €190/month)
Joining elements of a list if those elements are in between two whitespaces
Really bizarre dystopian children’s film with hundreds of young boys forced to play piano
Why would a life company agree to a 20-year guaranteed life annuity which is expected to pay out more than the principal?
What does Darth Vader think Obi-Wan's referring to when Obi says "If you strike me down..."
What are these tiny kidney bean sized things in my rotisserie chicken
Is it possible to get reverse life insurance?
Select subsets from a list based on a criterion?
Is the Summon Woodland Beings spell (to summon pixies) broken?
Christmas party and autism
90's or earlier book with a ship called Heinlein
Does a small cup of coffee result in a 45% reduced blood flow to the brain?
Why didn't Abraham ask the single best question?
How do I get the =LEFT function in excel, to also take the number zero as the first number?
Need a formula that looks at the first digit or letter in a cellExcel Formula To Get First Non-Zero Value in Row and Return Column HeaderMS Excel: Count the max spaces between a number frequencyExcel Formula To Get LAST Non-Zero Value in Row and Return Column HeaderHow to find the first non-zero number from the bottom up by referenced vehicle#?How to select the first number in cell in Excel?Searching an array from bottom to topHow to get continuous number based on item number for each category in excel?Excel: lookup the last non-zero, non-empty cell in filtered range
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
My data contains a column of room numbers. Each room number's first 2 digits is the floor number where the room is located. The =LEFT function works well for data that does not start with zero. The =LEFT function doesn't work well for data that starts with zero.
How can I get the formula to not ignore the first number when it is zero?
Room Number Formula Floor Number
1214 =LEFT (A2, 2) 12
2354 =LEFT (A2, 2) 23
1876 =LEFT (A2, 2) 18
1567 =LEFT (A2, 2) 15
0403 =LEFT (A2, 2) 40* (should be level 04)
1918 =LEFT (A2, 2) 19
0910 =LEFT (A2, 2) 91* (should be level 09)
microsoft-excel worksheet-function microsoft-excel-2010 microsoft-excel-2007
add a comment
|
My data contains a column of room numbers. Each room number's first 2 digits is the floor number where the room is located. The =LEFT function works well for data that does not start with zero. The =LEFT function doesn't work well for data that starts with zero.
How can I get the formula to not ignore the first number when it is zero?
Room Number Formula Floor Number
1214 =LEFT (A2, 2) 12
2354 =LEFT (A2, 2) 23
1876 =LEFT (A2, 2) 18
1567 =LEFT (A2, 2) 15
0403 =LEFT (A2, 2) 40* (should be level 04)
1918 =LEFT (A2, 2) 19
0910 =LEFT (A2, 2) 91* (should be level 09)
microsoft-excel worksheet-function microsoft-excel-2010 microsoft-excel-2007
1
I think we clobbered our edits together. I've code-formatted your data so it looks good.
– Michael Frank
Aug 6 at 3:45
Thanks @MichaelFrank!!
– Jefferson
Aug 6 at 3:46
add a comment
|
My data contains a column of room numbers. Each room number's first 2 digits is the floor number where the room is located. The =LEFT function works well for data that does not start with zero. The =LEFT function doesn't work well for data that starts with zero.
How can I get the formula to not ignore the first number when it is zero?
Room Number Formula Floor Number
1214 =LEFT (A2, 2) 12
2354 =LEFT (A2, 2) 23
1876 =LEFT (A2, 2) 18
1567 =LEFT (A2, 2) 15
0403 =LEFT (A2, 2) 40* (should be level 04)
1918 =LEFT (A2, 2) 19
0910 =LEFT (A2, 2) 91* (should be level 09)
microsoft-excel worksheet-function microsoft-excel-2010 microsoft-excel-2007
My data contains a column of room numbers. Each room number's first 2 digits is the floor number where the room is located. The =LEFT function works well for data that does not start with zero. The =LEFT function doesn't work well for data that starts with zero.
How can I get the formula to not ignore the first number when it is zero?
Room Number Formula Floor Number
1214 =LEFT (A2, 2) 12
2354 =LEFT (A2, 2) 23
1876 =LEFT (A2, 2) 18
1567 =LEFT (A2, 2) 15
0403 =LEFT (A2, 2) 40* (should be level 04)
1918 =LEFT (A2, 2) 19
0910 =LEFT (A2, 2) 91* (should be level 09)
microsoft-excel worksheet-function microsoft-excel-2010 microsoft-excel-2007
microsoft-excel worksheet-function microsoft-excel-2010 microsoft-excel-2007
edited Aug 6 at 3:45
Michael Frank
7,1911 gold badge33 silver badges49 bronze badges
7,1911 gold badge33 silver badges49 bronze badges
asked Aug 6 at 3:42
JeffersonJefferson
1014 bronze badges
1014 bronze badges
1
I think we clobbered our edits together. I've code-formatted your data so it looks good.
– Michael Frank
Aug 6 at 3:45
Thanks @MichaelFrank!!
– Jefferson
Aug 6 at 3:46
add a comment
|
1
I think we clobbered our edits together. I've code-formatted your data so it looks good.
– Michael Frank
Aug 6 at 3:45
Thanks @MichaelFrank!!
– Jefferson
Aug 6 at 3:46
1
1
I think we clobbered our edits together. I've code-formatted your data so it looks good.
– Michael Frank
Aug 6 at 3:45
I think we clobbered our edits together. I've code-formatted your data so it looks good.
– Michael Frank
Aug 6 at 3:45
Thanks @MichaelFrank!!
– Jefferson
Aug 6 at 3:46
Thanks @MichaelFrank!!
– Jefferson
Aug 6 at 3:46
add a comment
|
5 Answers
5
active
oldest
votes
If all the room numbers are meant to have 4 digits, and the four digits are achieved by formatting numbers less than 1000 with custom format "0000", then you can use
=LEFT(TEXT(A1,"0000"),2)
Edit: FWIW, this approach also works if the value is text.

add a comment
|
It seems you store room numbers as numbers, this case LEFT is not the best choice, use INT instead:
=INT(A2/100)
To keep the leading zero (04 instead of 4) you need to set number format of the cells to "Custom" with "type": 00
Thanks @fixer1234 for the comment!

9
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
2
This is also theQUOTIENTfunction:=QUOTIENT(A1,100)
– Chronocidal
Aug 7 at 15:54
3
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
2
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
add a comment
|
This sounds like it's a cell formatting issue. Make sure your Room Number column is formatted as Text and not General or Number.

This is from LibreOffice, but the behaviour is the same for Excel as long as the cell is formatted as Text.
Based on your comment that you simply custom formatted the value to show a leading 0, you can use this formula to check if there is a leading 0 on a room name and then add one if there isn't:
=IF(LEFT(A1,1)=0,LEFT(A1,2),CONCAT("0",LEFT(A1,1)))

When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
1
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
1
or just=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
2
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
|
show 2 more comments
Michael Frank figured out what's going on. A custom format of "0000" adds leading zeros as necessary to display four digits, but it doesn't alter what is in the cell. If you apply that format to 102, the cell will display 0102, but if you use LEN() to test the number of characters, that will show three. You can use this for a solution with a short formula.

In A1, I've got the value 102. In A2 is the same value, custom formatted 0000. The formula in B2 is:
=LEFT(REPT("0",4-LEN(A2))&A2,2)
This subtracts the actual length of the value in A2 from 4, then creates the resulting count of leading zeros and concatenates that to the actual value in A2. Then it takes the left two characters of the result.
Row 3 shows the result when the value in column A is actually four characters.
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
1
or simpler:=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
add a comment
|
There are already good answers available to your question, but if you want to make this work with the same formula you had used initially:
=LEFT(A1,2)
then just prefix ' (single quote before the number).
See the below screenshot for your reference
e.g., instead of just 0403, make it '0403 and then apply the same formula.
Screenshot for reference below
Add prefix before the number:

Works with the same formula:

But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the=LEFT(A1,2)formula and seems like it might be less work..
– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "3"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1468068%2fhow-do-i-get-the-left-function-in-excel-to-also-take-the-number-zero-as-the-fi%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
If all the room numbers are meant to have 4 digits, and the four digits are achieved by formatting numbers less than 1000 with custom format "0000", then you can use
=LEFT(TEXT(A1,"0000"),2)
Edit: FWIW, this approach also works if the value is text.

add a comment
|
If all the room numbers are meant to have 4 digits, and the four digits are achieved by formatting numbers less than 1000 with custom format "0000", then you can use
=LEFT(TEXT(A1,"0000"),2)
Edit: FWIW, this approach also works if the value is text.

add a comment
|
If all the room numbers are meant to have 4 digits, and the four digits are achieved by formatting numbers less than 1000 with custom format "0000", then you can use
=LEFT(TEXT(A1,"0000"),2)
Edit: FWIW, this approach also works if the value is text.

If all the room numbers are meant to have 4 digits, and the four digits are achieved by formatting numbers less than 1000 with custom format "0000", then you can use
=LEFT(TEXT(A1,"0000"),2)
Edit: FWIW, this approach also works if the value is text.

edited Aug 8 at 0:16
answered Aug 6 at 5:28
teylynteylyn
18.9k2 gold badges27 silver badges41 bronze badges
18.9k2 gold badges27 silver badges41 bronze badges
add a comment
|
add a comment
|
It seems you store room numbers as numbers, this case LEFT is not the best choice, use INT instead:
=INT(A2/100)
To keep the leading zero (04 instead of 4) you need to set number format of the cells to "Custom" with "type": 00
Thanks @fixer1234 for the comment!

9
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
2
This is also theQUOTIENTfunction:=QUOTIENT(A1,100)
– Chronocidal
Aug 7 at 15:54
3
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
2
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
add a comment
|
It seems you store room numbers as numbers, this case LEFT is not the best choice, use INT instead:
=INT(A2/100)
To keep the leading zero (04 instead of 4) you need to set number format of the cells to "Custom" with "type": 00
Thanks @fixer1234 for the comment!

9
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
2
This is also theQUOTIENTfunction:=QUOTIENT(A1,100)
– Chronocidal
Aug 7 at 15:54
3
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
2
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
add a comment
|
It seems you store room numbers as numbers, this case LEFT is not the best choice, use INT instead:
=INT(A2/100)
To keep the leading zero (04 instead of 4) you need to set number format of the cells to "Custom" with "type": 00
Thanks @fixer1234 for the comment!

It seems you store room numbers as numbers, this case LEFT is not the best choice, use INT instead:
=INT(A2/100)
To keep the leading zero (04 instead of 4) you need to set number format of the cells to "Custom" with "type": 00
Thanks @fixer1234 for the comment!

edited Aug 6 at 10:47
answered Aug 6 at 5:44
Máté JuhászMáté Juhász
16.2k6 gold badges37 silver badges55 bronze badges
16.2k6 gold badges37 silver badges55 bronze badges
9
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
2
This is also theQUOTIENTfunction:=QUOTIENT(A1,100)
– Chronocidal
Aug 7 at 15:54
3
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
2
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
add a comment
|
9
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
2
This is also theQUOTIENTfunction:=QUOTIENT(A1,100)
– Chronocidal
Aug 7 at 15:54
3
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
2
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
9
9
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
Good answer. - I would argue that the "Room numbers" are not really numbers, but more room-identifiers and type text is appropriate. My experience as an API developer has lead me to follow this rule of thumb: "If it doesn't make sense to add or multiply it, it should probably be saved as text rather than a number" - even more true for combined keys where certain "digits" have meaning.
– Falco
Aug 7 at 14:13
2
2
This is also the
QUOTIENT function: =QUOTIENT(A1,100)– Chronocidal
Aug 7 at 15:54
This is also the
QUOTIENT function: =QUOTIENT(A1,100)– Chronocidal
Aug 7 at 15:54
3
3
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
@Falco Indeed, it's possible that at some point in the future, a "room number" of "1214A" will exist, and treating what is fundamentally a string as if it were a number will fail.
– Monty Harder
Aug 7 at 16:59
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
my approach works with strings as well as with numbers. I updated my answer with a screenshot.
– teylyn
Aug 8 at 0:16
2
2
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
Int he same category: phone numbers aren't numbers either.
– MSalters
Aug 8 at 12:27
add a comment
|
This sounds like it's a cell formatting issue. Make sure your Room Number column is formatted as Text and not General or Number.

This is from LibreOffice, but the behaviour is the same for Excel as long as the cell is formatted as Text.
Based on your comment that you simply custom formatted the value to show a leading 0, you can use this formula to check if there is a leading 0 on a room name and then add one if there isn't:
=IF(LEFT(A1,1)=0,LEFT(A1,2),CONCAT("0",LEFT(A1,1)))

When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
1
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
1
or just=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
2
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
|
show 2 more comments
This sounds like it's a cell formatting issue. Make sure your Room Number column is formatted as Text and not General or Number.

This is from LibreOffice, but the behaviour is the same for Excel as long as the cell is formatted as Text.
Based on your comment that you simply custom formatted the value to show a leading 0, you can use this formula to check if there is a leading 0 on a room name and then add one if there isn't:
=IF(LEFT(A1,1)=0,LEFT(A1,2),CONCAT("0",LEFT(A1,1)))

When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
1
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
1
or just=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
2
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
|
show 2 more comments
This sounds like it's a cell formatting issue. Make sure your Room Number column is formatted as Text and not General or Number.

This is from LibreOffice, but the behaviour is the same for Excel as long as the cell is formatted as Text.
Based on your comment that you simply custom formatted the value to show a leading 0, you can use this formula to check if there is a leading 0 on a room name and then add one if there isn't:
=IF(LEFT(A1,1)=0,LEFT(A1,2),CONCAT("0",LEFT(A1,1)))

This sounds like it's a cell formatting issue. Make sure your Room Number column is formatted as Text and not General or Number.

This is from LibreOffice, but the behaviour is the same for Excel as long as the cell is formatted as Text.
Based on your comment that you simply custom formatted the value to show a leading 0, you can use this formula to check if there is a leading 0 on a room name and then add one if there isn't:
=IF(LEFT(A1,1)=0,LEFT(A1,2),CONCAT("0",LEFT(A1,1)))

edited Aug 6 at 3:59
answered Aug 6 at 3:47
Michael FrankMichael Frank
7,1911 gold badge33 silver badges49 bronze badges
7,1911 gold badge33 silver badges49 bronze badges
When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
1
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
1
or just=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
2
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
|
show 2 more comments
When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
1
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
1
or just=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
2
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
When I format it as text, the room number 0403 becomes 403. The =LEFT function will grab the number 40 as the floor number.
– Jefferson
Aug 6 at 3:49
1
1
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
You have to enter the room numbers into the cell after you format it to Text, otherwise it will have already dropped the leading 0.
– Michael Frank
Aug 6 at 3:50
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
When I extract the data from the system, rooms located on single digit floors is format as E.g. 405, 905. I added the custom format 0000 thinking that this will let me use the =LEFT function but the function is ignoring the zero in front of it.
– Jefferson
Aug 6 at 3:52
1
1
or just
=LEFT(TEXT(A1,"0000"),2)– teylyn
Aug 6 at 5:29
or just
=LEFT(TEXT(A1,"0000"),2)– teylyn
Aug 6 at 5:29
2
2
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
@Jefferson "When I format it as text, the room number 0403 becomes 403." - That's good! Before you formatted it as text, there was a problem (namely, the cell had the wrong contents), but the problem was hidden. Formatting it as text revealed the problem.
– Tanner Swett
Aug 6 at 18:38
|
show 2 more comments
Michael Frank figured out what's going on. A custom format of "0000" adds leading zeros as necessary to display four digits, but it doesn't alter what is in the cell. If you apply that format to 102, the cell will display 0102, but if you use LEN() to test the number of characters, that will show three. You can use this for a solution with a short formula.

In A1, I've got the value 102. In A2 is the same value, custom formatted 0000. The formula in B2 is:
=LEFT(REPT("0",4-LEN(A2))&A2,2)
This subtracts the actual length of the value in A2 from 4, then creates the resulting count of leading zeros and concatenates that to the actual value in A2. Then it takes the left two characters of the result.
Row 3 shows the result when the value in column A is actually four characters.
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
1
or simpler:=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
add a comment
|
Michael Frank figured out what's going on. A custom format of "0000" adds leading zeros as necessary to display four digits, but it doesn't alter what is in the cell. If you apply that format to 102, the cell will display 0102, but if you use LEN() to test the number of characters, that will show three. You can use this for a solution with a short formula.

In A1, I've got the value 102. In A2 is the same value, custom formatted 0000. The formula in B2 is:
=LEFT(REPT("0",4-LEN(A2))&A2,2)
This subtracts the actual length of the value in A2 from 4, then creates the resulting count of leading zeros and concatenates that to the actual value in A2. Then it takes the left two characters of the result.
Row 3 shows the result when the value in column A is actually four characters.
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
1
or simpler:=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
add a comment
|
Michael Frank figured out what's going on. A custom format of "0000" adds leading zeros as necessary to display four digits, but it doesn't alter what is in the cell. If you apply that format to 102, the cell will display 0102, but if you use LEN() to test the number of characters, that will show three. You can use this for a solution with a short formula.

In A1, I've got the value 102. In A2 is the same value, custom formatted 0000. The formula in B2 is:
=LEFT(REPT("0",4-LEN(A2))&A2,2)
This subtracts the actual length of the value in A2 from 4, then creates the resulting count of leading zeros and concatenates that to the actual value in A2. Then it takes the left two characters of the result.
Row 3 shows the result when the value in column A is actually four characters.
Michael Frank figured out what's going on. A custom format of "0000" adds leading zeros as necessary to display four digits, but it doesn't alter what is in the cell. If you apply that format to 102, the cell will display 0102, but if you use LEN() to test the number of characters, that will show three. You can use this for a solution with a short formula.

In A1, I've got the value 102. In A2 is the same value, custom formatted 0000. The formula in B2 is:
=LEFT(REPT("0",4-LEN(A2))&A2,2)
This subtracts the actual length of the value in A2 from 4, then creates the resulting count of leading zeros and concatenates that to the actual value in A2. Then it takes the left two characters of the result.
Row 3 shows the result when the value in column A is actually four characters.
edited Aug 6 at 5:02
answered Aug 6 at 4:53
fixer1234fixer1234
22.8k15 gold badges59 silver badges91 bronze badges
22.8k15 gold badges59 silver badges91 bronze badges
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
1
or simpler:=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
add a comment
|
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
1
or simpler:=LEFT(TEXT(A1,"0000"),2)
– teylyn
Aug 6 at 5:29
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
Nice, a much simpler formula than my quick example. +1
– Michael Frank
Aug 6 at 5:03
1
1
or simpler:
=LEFT(TEXT(A1,"0000"),2)– teylyn
Aug 6 at 5:29
or simpler:
=LEFT(TEXT(A1,"0000"),2)– teylyn
Aug 6 at 5:29
add a comment
|
There are already good answers available to your question, but if you want to make this work with the same formula you had used initially:
=LEFT(A1,2)
then just prefix ' (single quote before the number).
See the below screenshot for your reference
e.g., instead of just 0403, make it '0403 and then apply the same formula.
Screenshot for reference below
Add prefix before the number:

Works with the same formula:

But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the=LEFT(A1,2)formula and seems like it might be less work..
– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
add a comment
|
There are already good answers available to your question, but if you want to make this work with the same formula you had used initially:
=LEFT(A1,2)
then just prefix ' (single quote before the number).
See the below screenshot for your reference
e.g., instead of just 0403, make it '0403 and then apply the same formula.
Screenshot for reference below
Add prefix before the number:

Works with the same formula:

But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the=LEFT(A1,2)formula and seems like it might be less work..
– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
add a comment
|
There are already good answers available to your question, but if you want to make this work with the same formula you had used initially:
=LEFT(A1,2)
then just prefix ' (single quote before the number).
See the below screenshot for your reference
e.g., instead of just 0403, make it '0403 and then apply the same formula.
Screenshot for reference below
Add prefix before the number:

Works with the same formula:

There are already good answers available to your question, but if you want to make this work with the same formula you had used initially:
=LEFT(A1,2)
then just prefix ' (single quote before the number).
See the below screenshot for your reference
e.g., instead of just 0403, make it '0403 and then apply the same formula.
Screenshot for reference below
Add prefix before the number:

Works with the same formula:

edited Aug 8 at 14:56
G-Man Says 'Reinstate Monica'
6,39711 gold badges27 silver badges65 bronze badges
6,39711 gold badges27 silver badges65 bronze badges
answered Aug 8 at 12:11
Subin_LearnerSubin_Learner
112 bronze badges
112 bronze badges
But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the=LEFT(A1,2)formula and seems like it might be less work..
– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
add a comment
|
But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the=LEFT(A1,2)formula and seems like it might be less work..
– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the
=LEFT(A1,2) formula and seems like it might be less work..– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
But it should be noted that this is essentially equivalent to Michael Frank’s answer, which also allows the user to use the
=LEFT(A1,2) formula and seems like it might be less work..– G-Man Says 'Reinstate Monica'
Aug 8 at 21:21
add a comment
|
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1468068%2fhow-do-i-get-the-left-function-in-excel-to-also-take-the-number-zero-as-the-fi%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I think we clobbered our edits together. I've code-formatted your data so it looks good.
– Michael Frank
Aug 6 at 3:45
Thanks @MichaelFrank!!
– Jefferson
Aug 6 at 3:46