Excel convert row into a table

October 25, 2010 at 05:33:45
Specs: Windows XP
Hi could anyone help me how to convert a row into a table
I need to convert a row 1 2 3 4 5 6 into a table

1 2 3
4 5 6

Thank you


See More: Excel convert row into a table

Report •

#1
October 25, 2010 at 06:18:40
I'm sure that you are going to need to give us more information about what you are trying to do.

Based on the example that you have provided, some very simple formulas will give you what you asked for:


      A    B    C    D    E    F
1     1    2    3    4    5    6
2    =A1  =B1  =C1
3    =D1  =E1  =D1




Report •

#2
October 25, 2010 at 06:45:53
Thank you for your reply. I have a time series of 50 observations but in order to process the data in fortran i need to organise it into a table of 4 columns.
Therefore, I guess that simple formula will not work. I have big array.

Report •

#3
October 25, 2010 at 07:29:52
This code will take a row of data that starts in A1 and convert it into a 4 column table starting in A2.

Sub FourCols()
'Find last column with data in Row 1
  lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
'Calculate how many sets of 4 we need
  setCount = Application.WorksheetFunction.RoundUp(lastCol / 4, 0) + 1
'Loop through Destination Rows
  For nxtDstRow = 2 To setCount
'Loop through Destination Columns
   For nxtDstCol = 1 To 4
'Increment Source Column
    nxtSrcCol = nxtSrcCol + 1
'Put values in cells
     Cells(nxtDstRow, nxtDstCol) = Cells(1, nxtSrcCol)
   Next
  Next
End Sub


Report •
Related Solutions


Ask Question