views:

368

answers:

2

I have survey results which are formatted in excel fine. I then need to show these results indivually wiht the headings on a presentable word doc or wewb page? s there any weay to do this.

For example:

column one - comlumn 2

result 1 - result 1

result 2 - result 2

to

comlumn 1

result one

column 2

result one

column 1

result 2

comlumn 2

result 2

sorry if that make no sense.

Thanks

+1  A: 

Sounds like you need to use "Mail Merge" from within word and then give the excel spreadsheet as the data source.

Allain Lalonde
A: 

There isn't much information to go by in your question, but it seems like you could use a macro to transform your data. I wrote a quick macro that takes data in the format you have presented and outputs it as you have specified.

I would use the macro below to create a new Worksheet in Excel and then manipulate it or paste it into Word as necessary. Without more information, there isn't more to say.

**Input**
Column A      Column B
Result A1     Result B1
Result A2     Result B2
**Output**
Column A
Result A1
Column B
Result B1
Column A
Result A2
Column B
Result B2

Here is the macro:

' Transforms the current sheet
' This method takes columns and rows and outputs a
' single This is not a transpose method, but similar.
Public Sub TransformSheet()
    Dim SourceSheet As Worksheet
    Dim ResultSheet As Worksheet
    Dim iSourceColumn As Long, iSourceRow As Long
    Dim iResultColumn As Long, iResultRow As Long
    Dim iHeaderRow As Long
    Dim UseCopyPaste As Boolean
    ' Change source and result sheets as necessary
    Set SourceSheet = ActiveSheet
    Set ResultSheet = ActiveWorkbook.Sheets("Sheet2")
    ' Options
    UseCopyPaste = True
    iHeaderRow = 1
    iResultColumn = 1
    iResultRow = 1
    ' Main Loop
    For iSourceRow = 2 To SourceSheet.UsedRange.Rows.Count
        For iSourceColumn = 1 To SourceSheet.UsedRange.Columns.Count
            If UseCopyPaste Then
                ' Header Column
                SourceSheet.Cells(iHeaderRow, iSourceColumn).Copy
                ResultSheet.Cells(iResultRow, iResultColumn).PasteSpecial xlPasteAll
                iResultRow = iResultRow + 1
                ' Result  Column
                SourceSheet.Cells(iSourceRow, iSourceColumn).Copy
                ResultSheet.Cells(iResultRow, iResultColumn).PasteSpecial xlPasteAll
                iResultRow = iResultRow + 1
            Else
                ' Header Column
                ResultSheet.Cells(iResultRow, iResultColumn) = _
                    SourceSheet.Cells(iHeaderRow, iSourceColumn).Value
                iResultRow = iResultRow + 1
                ' Result Column
                ResultSheet.Cells(iResultRow, iResultColumn) = _
                    SourceSheet.Cells(iSourceRow, iSourceColumn).Value
                iResultRow = iResultRow + 1
            End If
        Next iSourceColumn
    Next iSourceRow
End Sub
Ryan
Thank - you for your help, I can retrieve the data in xml sql or csv if any of those are easier to work with?#Thanks