Rather than have all my column names across the top of the worksheet, I'm looking to have them down the left hand side eg in Column A. The value of that will then be in Column B. I have used a recordset which loops through and pulls the first column correctly, but I need 30 more columns to do the same with the values. Where am I going wrong?
VBA Code:
' Run the query and store the retrieved data in the recordset
Set adoRecordset = adoCommand.Execute
' Set to the first empty row
intRow = 10
' Loop through the recordset
Do While Not adoRecordset.EOF
For rs = 0 To adoRecordset.Fields.Count - 1
With shtData
With .Cells(intRow, intCol + 1)
' Write the data to the cells
.Cells(intRow, intCol + 1).Value = adoRecordset.Fields(intCol).Name
.Cells(intRow, intCol + 2).Value = adoRecordset.Fields(intCol).Value
End With
End With
' Go to the next column in the record
Next rs
'Next intRow
' Go to the next row
intRow = intRow + 1
' Move to the next record in the recordset
adoRecordset.MoveNext
Loop
' Reset the recordset
Set adoRecordset = Nothing
' Reset the command
Set adoCommand = Nothing
' Closet and reset the connection
adoConnection.Close
Set adoConnection = Nothing