oSheet.Range("A" & teller + 1).EntireRow.Insert not doing anything

PoppeF

New Member
Joined
Jan 19, 2018
Messages
1
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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,919
Messages
6,175,368
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top