Hi all,
I'm new here.
I'm working on a vba project in access, and I'm exporting some data to an excel sheet.
I need to insert a row after each iteration, but the Entirerow.Insert just gets ignored completely.
No error, no row inserted, nothing. However the someField value gets written.
Any ideas are very welcome, because I'm really stuck on this one.
Set oExcel = CreateObject("Excel.Application")
path = GetCurLib()
teller = 8
Select Case someType
Case "x":
Set oBook = oExcel.Workbooks.Open(path & "basefile.xls")
Set oSheet = oBook.Worksheets(1)
strSQL = "SELECT * from tableXXX where ID= " & someID
Set rst = dbs.OpenRecordset(strSQL)
While Not rst.EOF
oSheet.Range("A" & teller).Value = rst!someField
oSheet.Range("A" & teller + 1).EntireRow.Insert
'oSheet.Rows(teller).EntireRow.Insert shift:=xlShiftDown
'oSheet.Rows(teller).EntireRow.Insert
rst.MoveNext
teller = teller + 1
Wend
oBook.SaveAs path & "outputfiles.xls"
End Select
oExcel.Quit
I'm new here.
I'm working on a vba project in access, and I'm exporting some data to an excel sheet.
I need to insert a row after each iteration, but the Entirerow.Insert just gets ignored completely.
No error, no row inserted, nothing. However the someField value gets written.
Any ideas are very welcome, because I'm really stuck on this one.
Set oExcel = CreateObject("Excel.Application")
path = GetCurLib()
teller = 8
Select Case someType
Case "x":
Set oBook = oExcel.Workbooks.Open(path & "basefile.xls")
Set oSheet = oBook.Worksheets(1)
strSQL = "SELECT * from tableXXX where ID= " & someID
Set rst = dbs.OpenRecordset(strSQL)
While Not rst.EOF
oSheet.Range("A" & teller).Value = rst!someField
oSheet.Range("A" & teller + 1).EntireRow.Insert
'oSheet.Rows(teller).EntireRow.Insert shift:=xlShiftDown
'oSheet.Rows(teller).EntireRow.Insert
rst.MoveNext
teller = teller + 1
Wend
oBook.SaveAs path & "outputfiles.xls"
End Select
oExcel.Quit