How insert rows in Excel sheet from Access VBA code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:
Please, I would appreciate you can show me the Access 2003 VBA code
necessary to insert 2 top rows in a previously existing Excel sheet and set
their cells to certain values.
Thanks very much.
Roberto
 
Air code:

Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRow As Range

Set oBook = GetObject("D:\Folder\Filename.xls")
Set oSheet = oBook.Sheets(1)

'insert 3 rows at top of sheeet
oSheet.Range("1:3").Insert xlShiftDown

'set value of a cell
oSheet.Cells(2, 2).Formula = "Hello World"

'...

oBook.Save
Set oSheet = Nothing
oBook.Close False
 
Back
Top