Code:' Slightly modified with lots of Comments Sub RickRothsteinsConcatenatingBalls() 'NOTE: Change the ## A1 to the address of the top left cell of your 'existing data and change the '### G1 to the address of the top left cell where you want the converted table to go to. **Const ExistingTableAnyCellLocation As String = "A1" '## **Const NewTableLHCornerLocation As String = "G1" '### ** **Dim SourceTableRange As Range 'Give a name and allow all methods and properties of range object to it **Set SourceTableRange = Range(ExistingTableAnyCellLocation).CurrentRegion ' Give this a specific Range. CurrentRegiuon Property applied to a cell returns a complete range incorporating that cell and any ranges that it either is in or touches **Dim SourceTableRangeTableRowsCount As Byte ' For a small Table allow it to hve up to 255 Rows **Let SourceTableRangeTableRowsCount = SourceTableRange.Rows.Count ' This returns the number of rows in the original table **Dim FinalTableFirstColumnRange As Range **Set FinalTableFirstColumnRange = Range(NewTableLHCornerLocation).Resize(SourceTableRangeTableRowsCount) ' Here the resize Property applied to the Range G1 (or Cell G1 here) returns a range increased by the row number, that is to say a range equal to the first column ** **SourceTableRange.Columns(1).Resize(, 2).Copy Destination:=FinalTableFirstColumnRange ' This is one way of copying the first two columns of the original table to The final table **FinalTableFirstColumnRange.Columns(2).NumberFormat = "@" ' This gives a format to the second column in the final Table ** **'FinalTableFirstColumnRange.Offset(0, 1) = _ **'Evaluate("IF(ROW()," & SourceTableRange.Columns(2).Address & "&"" - ""&" & SourceTableRange.Columns(3).Address & "&"" - ""&" & SourceTableRange.Columns(4).Address & ")") **'FinalTableFirstColumnRange.Offset(0, 1) = _ **'Evaluate("** " & SourceTableRange.Columns(2).Address & "&"" - ""&" & SourceTableRange.Columns(3).Address & "&"" - ""&" & SourceTableRange.Columns(4).Address & "") ** FinalTableFirstColumnRange.Offset(0, 1) = _ ****************Evaluate("** " & SourceTableRange.Columns(2).Address & "**** " & "&"" - ""&" & " " & SourceTableRange.Columns(3).Address & "**" & "&"" - ""&" & "" & SourceTableRange.Columns(4).Address & "") ** **SourceTableRange.Columns(5).Copy Destination:=FinalTableFirstColumnRange.Offset(, 2) 'Column 5 of Original table is copied to column 3 of the Final table by setting the destination to 2 colums offset from the first column ** **FinalTableFirstColumnRange.Cells(1, 0).Offset(0, 1).Value = "Numbers" ' The current heading in the second column is finally overwriten with "Numbers".**This is done here by putting the value"Numbers" in the cell which is offset by 1 column to the first cell in the Final Table First Column End Sub 'RickRothsteinsConcatenatingBalls() '




Reply With Quote
Bookmarks