Log in
x
or
x
x
Register
x

or
0
0
0
s2smodern

How to pad IP address with zero in Excel?

When receiving a sheet which contains some IP addresses with two digits in some segments, you may want to pad the IP address with zero to three digits in every segment as below screenshot shown. In this article, I introduce some tricks to quickly pad IP address in Excel.
doc pad ip with zero 1

Pad IP address with zero by formula

Pad IP address with zero by Defined Function


Pad IP address with zero by formula


Here is a long formula that can help you quickly pad IP address with zero.

Select a blank cell, type this formula,

=TEXT(LEFT(A1,FIND(".",A1)-1),"000.")&TEXT(MID(A1,FIND(".",A1)+1,FIND("~",SUBSTITUTE(A1,".","~",2))-FIND(".",A1)-1),"000.")&TEXT(MID(A1,FIND("~",SUBSTITUTE(A1,".","~",2))+1,FIND("~",SUBSTITUTE(A1,".","~",3))-FIND(".",A1)-1),"000.")&TEXT(MID(A1,FIND("~",SUBSTITUTE(A1,".","~",3))+1,LEN(A1)-FIND(".",A1)-1),"000")

A1 is the IP address you use, press Enter key, drag fill handle down to the cells needed this formula. see screenshot:

doc pad ip with zero 2
doc arrow down
doc pad ip with zero 3

Pad IP address with zero by Defined Function

If you are familiar with VBA code, here is a code that can also help you to pad IP address.

1. Press Alt + F11 keys to enable Microsoft Visual Basic for Applications window, click Insert > Module to create a new module. See screenshot:
doc pad ip with zero 4

2. In the Module script, paste below code to it, and then save the code and close the VBA window. See screenshot:

VBA: Pad IP Address

Function IP(Txt As String) As String
'UpdatebyExtendoffice20170725
    Dim xList As Variant
    Dim I As Long
    xList = Split(Txt, ".")
    For I = LBound(xList) To UBound(xList)
        xList(I) = Format(xList(I), "000")
    Next
    IP = Join(xList, ".")
End Function

doc pad ip with zero 5

3. Go to a blank cell which you will place the calculated result, type this formula =IP(A1), press Enter key, and drag fill handle down to the cells you need. See screenshot:

doc pad ip with zero 6 shot arrow right doc pad ip with zero 7

 


Exctract Email Address 

Kutools for Excel's Extract Email Address utility can quickly extract all email addresses from text strings to another location.
doc extract email address

Relative Articles


Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.