Hello,
I'm looking to copy a recordset to certain columns in excel. I am familiar with moving a complete recordset to a range in excel, but is there code to place:
rst.field(1) in cell("b10") and rst.field(4) in cell (I10)
here is my code to copy an entire recordset
Dim db As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim intLastCol As Integer
Const conMAX_ROWS = 20000
Set db = CurrentProject.Connection
rst.Open "qryAUVs", db, adOpenKeyset, adLockReadOnly
intLastCol = worksheet1.UsedRange.Columns.Count
With worksheet1
.Range(.Cells(1, 1), .Cells(conMAX_ROWS, _
intLastCol)).ClearContents
.Range("A2").CopyFromRecordset rst
End With
rst.Close
db.Close
This code works fine, but it puts the access data into excel, column for column(one next to the other). I'd like to put field1 in column B and Field 2 in column I. Any help is appreciated. Thx. Mike
I'm looking to copy a recordset to certain columns in excel. I am familiar with moving a complete recordset to a range in excel, but is there code to place:
rst.field(1) in cell("b10") and rst.field(4) in cell (I10)
here is my code to copy an entire recordset
Dim db As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim intLastCol As Integer
Const conMAX_ROWS = 20000
Set db = CurrentProject.Connection
rst.Open "qryAUVs", db, adOpenKeyset, adLockReadOnly
intLastCol = worksheet1.UsedRange.Columns.Count
With worksheet1
.Range(.Cells(1, 1), .Cells(conMAX_ROWS, _
intLastCol)).ClearContents
.Range("A2").CopyFromRecordset rst
End With
rst.Close
db.Close
This code works fine, but it puts the access data into excel, column for column(one next to the other). I'd like to put field1 in column B and Field 2 in column I. Any help is appreciated. Thx. Mike