Nested IFs to pad numbers with zeroes

Joseph Prespare

I am looking to pad a columns with zero's so that I can later concatenate it's value. It needs to 4 characters, so I am trying to use a Nested If Statement.

=IF(LEN(G2)=3,"0" & G2),IF(LEN(G2)=2,"00" & G2,G2)

I only get '#Value'. Where am I going wrong?

Jean-François Corbett

Don't reinvent the wheel: there is already a built-in function do to this.

=TEXT(G2,"0000")

enter image description here

Now, to answer your question specifically, the reason you got your error was that your IF functions weren't properly nested due to misplaced right brackets ).

Was:

=IF(LEN(G2)=3,"0" & G2),IF(LEN(G2)=2,"00" & G2,G2)
                      ^

Should be:

=IF(LEN(G2)=3,"0" & G2,IF(LEN(G2)=2,"00" & G2,G2))
                                                 ^

Still, this won't give you the expected results. Just go with the built-in TEXT function.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

simplifyfing a lot of ifs for numbers range folder check

분류에서Dev

How can I zero-pad numbers in a Batch FOR loop?

분류에서Dev

Matching numbers inside nested numbered groups

분류에서Dev

Strip zeroes with regex in csv file

분류에서Dev

JavaScript의 SUM IFS

분류에서Dev

IFS 이해

분류에서Dev

Matching fixed number of zeroes before new line

분류에서Dev

ARP messages padding with zeroes.. sometimes

분류에서Dev

Where does my leading zeroes go?

분류에서Dev

Overwriting the whole disk with zeroes (bad sectors)

분류에서Dev

IFS 문자 인쇄

분류에서Dev

Google Script IFS 조건

분류에서Dev

UNIX (AIX) Version of IFS <<< command

분류에서Dev

Bash IFS is ignoring the delimiter at the end of line

분류에서Dev

'IFS'는 무엇입니까?

분류에서Dev

"IFS = read -r line"이해

분류에서Dev

여러 ifs bash 결합

분류에서Dev

read -r vs read -r line and IFS

분류에서Dev

Is arithmetic expansion related to IFS in some way?

분류에서Dev

"for 루프"에서 IFS 사용

분류에서Dev

Using regex with IFS variable to split Bash string

분류에서Dev

쉘이 IFS = $ '\ n'를 IFS = 'n'으로 해석합니다.

분류에서Dev

널 IFS에 대해 기본 IFS 테스트

분류에서Dev

Glide Pad "Smooth Scroll"감지

분류에서Dev

How can i pad the edges of a rectangle with points?

분류에서Dev

reduce laptop touch pad sensitivity in ubuntu

분류에서Dev

Clear definition for the PHP str_pad() Function

분류에서Dev

SQLite에 해당하는 SUM IFS

분류에서Dev

셸, IFS, 읽기 및 표 작성