All,
I am not a programmer. But, I need a little programming help.
I created an Excel Macro. I need the first Macro (Name_IP) to call another Subroutine/Excel Macro (IPSplitAddresses).
When I use test data and the IPSplitAddresses as a Stand Alone Excel Macro/Subrountine, the IPSplitAddressess Excel Macro/Subrountine works just fine!
I receive an error when I copy IPSplitAddresses into Name_IP and try to run these two as one. Help!
I am not a programmer. But, I need a little programming help.
I created an Excel Macro. I need the first Macro (Name_IP) to call another Subroutine/Excel Macro (IPSplitAddresses).
When I use test data and the IPSplitAddresses as a Stand Alone Excel Macro/Subrountine, the IPSplitAddressess Excel Macro/Subrountine works just fine!
I receive an error when I copy IPSplitAddresses into Name_IP and try to run these two as one. Help!
Code:
Sub Name_IP()
'
' Name_IP Macro
'
'
Columns("A:A").EntireColumn.AutoFit
Columns("C:E").Select
Selection.Delete Shift:=xlToLeft
Columns("B:B").EntireColumn.AutoFit
Range("A1").Activate
'SplitIPAddress
Call IPSplitAddresses
Sub IPSplitAddresses()
' Dim arr As Variant
' Dim LastRow As Long, i As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 2 Step -1
arr = Split(Trim(Cells(i, 2)), " ") 'removes leading and trailing spaces, then creates a one-dimensional array of the ip addresses
If UBound(arr) <> -1 Then
Rows(i + 1).EntireRow.Resize(UBound(arr) + 1).Insert 'inserts blank rows equal to the number of ip addresses
Range(Cells(i + 1, 1), Cells(i + UBound(arr) + 1, 1)).Value = Cells(i, 1) 'fills Column A with the server name
Range(Cells(i + 1, 3), Cells(i + UBound(arr) + 1, 3)).Value = Cells(i, 3) 'fills Column C with the System note
Range(Cells(i + 1, 2), Cells(i + UBound(arr) + 1, 2)).Value = WorksheetFunction.Transpose(Split(Cells(i, 2), " ")) 'fills Column B with the ip addresses
Rows(i).Delete
End If
Next i
End Sub