Version Details Version Date Edited by Section/s Comments 1.0 22-02-2012 Rajiv Bhardwaj All First Draft 1.1 19-06-2012 Rajiv Bhardwaj All Added four more functions, Removed “RB_” prefix from function names
Purpose:Provide Introduction to Excel based IP functions created by me.Provide Instructions for Installation and operating the IP Functions .Scope:Provide Excel based IP functions for easier IP Planning.Provide Excel based IP functions for creating automated templates.
MotivationAfter I got tired with manually modifying IP address in excel, I decided to give a tryto creating some kind of formulae.I got some success with inbuilt “left” & “right” functions. e.g. by using somethinglike this to increment the IP address at position A1.LEFT(A1,FIND(“.”,A1,FIND(“.”,A1,FIND(“.”,A1,1)+1)+1))&RIGHT(A1,LEN(A1)-FIND_(“.”,A1,FIND(“.”,A1,FIND(“.”,A1,1)+1)+1))+1
Limitation of using FormulaeBut soon it became quite cumbersome because of 3 reasons.1. Every time I wanted to use this formula I had to change the reference cell ID “A1″manually. It defeated the original purpose of automation.2. It didn’t work well for changing the Class A or B IP Subnets i.e. updating any ofthe first three “parts” of IP address.3. As I started working on some IP hungry nodes. Handling of huge number of IPsbecame almost impossible by this method.To overcome these limitations I tried to create VBA based functions which areeasier to use and provide more functionalities.I didn’t have much experience with macros and VBA, but still was able to create aset of working functions.
IP FunctionsI have complied all the IP address related functions in Add-in format. This way it iseasy to share all the functions without much effort on the end user part.Although, .xla format is not fully portable as excel sheets created by one usercannot be used by another user without updating the links. But it’s the easiest wayto transfer reusable functions.This Add-in RBIPFx include following functions in present version (0.3).1. IP_Bits2Mask2. IP_ErrChk3. IP_Hosts4. IP_IP2Mbits5. IP_Mod6. IP_NextSub
IP Functions7. IP_Bcast8. IP_Count9. IP_IsExist10. IP_Mask2Bits11. IP_Subnet
Installing RBIPFx Addin -I1. First move the add-in file (“.xla”) to “C:Addins” folder2. For Excel 2003 or older, go to addins menu by selecting Tools->Add-ins.3. Then choose the desired add-in from list. Add-in will appear in the list if youhave copied it to the right Add-in folder as described in step 1.4. If Add-in is not displayed in the list then you can use the browse button to locatethe Add-in File.
Installing RBIPFx Addin -IIFor Office 2007 or later:1. First move the add-in file (“.xla”) to “C:Addins” folder2. Click on the Office button in top left corner.3. Then choose excel options.
Installing RBIPFx Addin -III4. Select “Add-ins” , choose Manage “Excel Add-ins” and click Go.5. Then choose the RBIPFx.xla add-in from list and click OK. Add-in will appear inthe list if you have copied it to the right Add-in folder as described in step 1.
Installing RBIPFx Addin -IV6. If Add-in is not displayed in the list then you can use the browse button to locatethe Add-in File.7. If Add-in is correctly installed then it may show a relevant message.8. Once installation is complete then you can see the “compatible” add-ins in theAdd-ins tab of office ribbon. (Optional)
IP_Mod: IP Modification FunctionIP_Mod: This is the primary function of RBIPFx Excel Add-in. It modifies the IPaddresses.Syntax: RB_Mod_IP( IP address, optional Step, Optional Part)Parameters:IP Address: As the name suggest is IPV4 IP address which you want to modify.Step: It is the number by which you want to increment or decrement the given IPaddress. It is optional and default value of this parameter is 1.Part: It is the part of IP address you want to modify. As IPv4 address as 4 partsseparated by “.”.i.e For IP 10.11.12.13, Part 1 =10, part 2=11, Part3 =12 & Part4 =13.It is also optional parameter & default value of this part is 4. i.e. last part (Class Csubnet)
IP_Mod: IP Modification Function - UsageUSAGE: Following are some of the ways, this function can be used.i) You can increment the IP by one just by using the IP address parameter. i.e.IP_Mod(“10.11.12.13″,1) will give 10.11.12.14.
IP_Mod: IP Modification Function - UsageAs I have set the value of Step to be 1 by default so IP_Mod(“10.11.12.13″) will alsodo.
IP_Mod: IP Modification Function - UsageDragging this function in excel column will give you a series of IPs.
IP_Mod: IP Modification Function - UsageBut if you want to increment the IP with bigger value then you need to use theparameter STEP.e.gIP_Mod(“10.11.12.13″, 10) will give you 10.11.12.23.
IP_Mod: IP Modification Function - CIDRIP address with subnet maskbits (e.g. xx.xx.xx.xx/24) is also used in the IP domainThis function can handle that too. It automatically detects the subnet maskseparator (“/”) and uses the same format for output.e.gIP_Mod(“10.11.12.13/24″,10,3) will give you 10.11.22.13/24 as output.
IP_Mod: IP Modification Function - DecrementIf you want to decrement an IP address instead of incrementing then you can dothat too by just giving a negative Step Value.e.g IP_Mod(10.11.12.13, -5) will give 10.11.12.8
IP_Mod: IP Modification Function - Error HandlingError Handling: It can handle basic error situations.if you input a step value more than 255 or less than -255. Function will return anerror.e.g.IP_Mod(10.11.12.13, 258) will give “#NUM” as return. This error is inline with basicexcel errors as it signifies that wrong value of number is being used.
IP_Mod: IP Modification Function - Error HandlingI initially had pop-up message for such situations but it becomes quite irritating ifwe have a large sheet full of IP addresses.One more situation which I have captured is that sometimes input is well withinrange but the resultant IP is out of range. It also generates error in such situation.e.g. IP_Mod(10.11.12.13, 245) will give “#NUM” error as resultant IP 10.11.12.258is not the valid one. For me this error functionality is a real life saver as I tend toforget this “255″ limit.
IP_NextSub: Next Subnet FunctionThis function calculates next IP subnet. Subnet mask is mandatory parameter forthis function.This function can also work with CIDR notation.If both CIDR notation and Maskbit parameter are given, maskbit parameter is givenhigher priority.
IP_ErrChkFunction checks if IP Address is valid or not
IP_HostsFunction calculates number of hosts from mask bits.It automatically deducts 2 IPs from the number of hosts to compensate for networkaddress & broadcast address
IP_IP2MbitsThis function calculates the Mask Bits (Subnet Mask) for the required number ofIPs.e.g. If we require 11 IPs then a IP subnet with subnet mask of /28 is required.
IP_SubnetThis function calculates the Subnet (Network Address) for the given IPe.g. Subnet for 10.1.1.99/28 is calculated to be 10.1.1.96.
IP_BcastThis function calculates the Broadcast address for given IP .e.g. Broadcast address for 10.1.1.99/28 is 10.1.1.111
IP_Mask2BitsThis function calculates the Mask Bits from the Subnet mask in “x.x.x.x” format.e.g. Subnet mask 255.255.255.240 is equivalent to 28 maskbits i.e. /28.
IP_IsExistThis is a boolean function to check if one IP exists in an IP range (Subnet). It alsochecks if an IP subnet overlaps with other IP subnet.First argument is the IP range, in which the given IP (subnet) will be checkedSecond argument is the IP (Subnet) to be checkede.g. We can check if 10.1.1.112 exists with in 10.1.1.96/28.
IP_CountThis function counts the occurrence of an IP address in a given range of IP networkaddresses (subnets). It can be used to check the overlapping subnets in an IP PlanFirst argument is the IP range, in which the given IP (subnet) will be checkedSecond argument is the IP (Subnet) to be checked