'# 1 - Return Subnet Mask in dotted decimal # '# IP Subnet Calculator by Marcus Mansfield # Obviously, the X, Y/Z can be cell references.Įnjoy Public Function IPSubnetCalc(intFn%, IPandMaskInput$) X = 1 to 5 - See below for what each option does. Input is =IPSubnetCalc(X, YY.YY.YY.YY/ZZ ) Its very basic, but it does exactly what is says on the tin and works for me. I'm going to assume you know how to add a VBA Function ( Or Macro etc ), If not I'll hope someone will reply to this thread with a simple How To. IPSubnetCalc = "Bitmask Error : Range 8 - 32, Excl. IPSubnetCalc = "Value Error, Octet > 255" If IPOctet1 > 255 Or IPOctet2 > 255 Or IPOctet3 > 255 Or IPOctet4 > 255 Then IPOctet4 = Mid(IPandMaskInput, Dot3 + 1, Slash1 - Dot3 - 1)īitMask = Right(IPandMaskInput, Len(IPandMaskInput) - Slash1) IPOctet3 = Mid(IPandMaskInput, Dot2 + 1, Dot3 - Dot2 - 1) IPOctet2 = Mid(IPandMaskInput, Dot1 + 1, Dot2 - Dot1 - 1) IPOctet1 = Mid(IPandMaskInput, 1, Dot1 - 1) If Dot1 = 0 Or Dot2 = 0 Or Dot3 = 0 Or Slash1 = 0 Then ' 6 - Return Total Number of Host in the Network.ĭim IPOctet1%, IPOctet2%, IPOctet3%, IPOctet4%ĭim MaskOctet1%, MaskOctet2%, MaskOctet3%, MaskOctet4%ĭim IPNetwork1BIN$, IPNetwork2BIN$, IPNetwork3BIN$, IPNetwork4BIN$ĭot2 = InStr(Dot1 + 1, IPandMaskInput, ".")ĭot3 = InStr(Dot2 + 1, IPandMaskInput, ".") ' 1 - Return Subnet Mask in dotted decimal ' Author: Rui Sousa Change: Add funtion 6 to return number os hosts ' IP Subnet Calculator by Marcus Mansfield Rui Public Function IPSubnetCalc(intFn%, IPandMaskInput$) I've added a new option to calculate the number of available hosts in a network.
0 Comments
Leave a Reply. |