Split Column based on contents

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the Board!

This is a crude macro (it has far too many "activates" and "selects" to be considered sleek and elegant), but I was just trying to whip something up before I leave for the day and didn't have time to clean it up.

However, it should work just fine and do what you want. I even name each tab name with the server name (minus the slashes).
Code:
Sub MyServerMacro()
 
    Dim myStartSheet As String
    Dim myNewSheetName As String
    Dim myLastRow As Long
    Dim myValue As String
    Dim i As Long
 
    Application.ScreenUpdating = False
 
'   Capture name of data sheet
    myStartSheet = ActiveSheet.Name
 
'   Assuming all data is in column A, find last row of data
    myLastRow = Cells(Rows.Count, "A").End(xlUp).Row
 
'   Loop through all cells, populating values
    For i = 1 To myLastRow
        Sheets(myStartSheet).Activate
        myValue = Cells(i, "A")
        If Left(myValue, 2) = "\\" Then
            myNewSheetName = Replace(myValue, "\", "")
            Sheets.Add After:=Sheets(Sheets.Count)
            ActiveSheet.Name = myNewSheetName
            Range("A1") = myValue
        Else
            Sheets(myNewSheetName).Activate
            Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Activate
            ActiveCell = myValue
        End If
    Next i
 
    Application.ScreenUpdating = True
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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