Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]() To split to columns, with some maximum number of columns, you can try this macro: ========================================== Sub SplitToColumns() Const MaxCols As Long = 256 'set this to whatever or use inputbox Const Comma As String = "," Dim c As Range Dim i As Long Dim sSplitArray() As String For Each c In Selection sSplitArray = Split(c.Value, Comma) For i = 0 To UBound(sSplitArray) c(1 + Int(i / MaxCols), 2 + i Mod MaxCols).Value = Replace(Trim(sSplitArray(i)), vbLf, "") Next i Next c End Sub ============================================= --ron I noticed my newsreader wrapped a line in this second macro in the wrong spot. So as to prevent that, I forced a line break appropriately: ============================================= Sub SplitToColumns() Const MaxCols As Long = 3 'set this to whatever or use inputbox Const Comma As String = "," Dim c As Range Dim i As Long Dim sSplitArray() As String For Each c In Selection sSplitArray = Split(c.Value, Comma) For i = 0 To UBound(sSplitArray) c(1 + Int(i / MaxCols), 2 + i Mod MaxCols).Value = _ Replace(Trim(sSplitArray(i)), vbLf, "") Next i Next c End Sub =========================================== --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Splitting a Cell | Excel Worksheet Functions | |||
splitting cell | Excel Worksheet Functions | |||
Splitting a cell by number of characters from the end | Excel Discussion (Misc queries) | |||
Splitting a cell | Excel Worksheet Functions | |||
Splitting a Cell | Excel Worksheet Functions |