IP Control with Excel + VBA

0

I'm building some functions for analyzing a table of IPs. I just used VBA for the first time in my life and in my searches I did not find anything that could help me.

I need to create a function that searches for the least number that does not exist in a column in Excel. The user should pass the initial and final value, for example 5777 and 6287. The function should search the default column (which will be sorted) between these indexes and, when finding a non existent index, inform the user.

These indexes represent a transformation in IP and the interval between them represents a subnet. When it returns me the lowest available index, the inverse transformation will show me the lowest free IP in that range.

I know I could create iterations from the initial index and at each iteration I compare the index with all available indexes. However, this would require two iterations and in case there are no addresses available, it would do m ^ n (m = qtd of IPs used throughout the network and n = amount of IPs in the subnet). That would be an absurd number of iterations for a 512 IPs subnet.

Would there be some other way to do this without too much code execution?

    
asked by anonymous 08.08.2014 / 01:37

1 answer

2

See the picture if that would be enough.

For ease of gluing, the formula is:

=SE(É.NÃO.DISP(PROCV( <número de IP da lista completa>; <lista de IPs já utilizados, pode ser um intervalo nomeado>; 1; FALSO)); "Texto para Livre"; "Texto para em uso")

Detail, although you mention that the list of IPs in use is in ascending order, so the formula has been configured, that does not matter.

    
08.08.2014 / 20:25