Ticker

6/recent/ticker-posts

gg

Sub SplitColumnsIntoSheets()
    Dim ws As Worksheet, newWs As Worksheet
    Dim totalCols As Long, groupSize As Long, startCol As Long, endCol As Long
    Dim newSheetName As String
    Dim i As Long
    
    Set ws = ThisWorkbook.Sheets("Sheet1") ' Change to your source sheet name
    totalCols = 36 ' Total number of columns
    groupSize = 4 ' Number of columns per group
    
    For i = 1 To totalCols Step groupSize
        startCol = i
        endCol = i + groupSize - 1
        If endCol > totalCols Then endCol = totalCols
        
        ' Create new sheet
        newSheetName = "Cols_" & startCol & "_to_" & endCol
        Set newWs = ThisWorkbook.Sheets.Add
        newWs.Name = newSheetName
        
        ' Copy data
        ws.Range(ws.Cells(1, startCol), ws.Cells(ws.Rows.Count, endCol)).Copy
        newWs.Range("A1").PasteSpecial xlPasteAll
    Next i
    
    Application.CutCopyMode = False
End Sub

Ad Code

Responsive Advertisement