Calling a Subrountine

tjreeddoc

New Member
Joined
Nov 2, 2016
Messages
14
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!





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
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hard to tell what code belongs to what macro, but for starters, change the line

Call IPSplitAddresses
to

Run "IPSplitAddresses"

and delete the line
Sub IPSplitAddresses()
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,362
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top