Moving to the next line to populate an excel file from VBA
Posted
by
edmon
on Super User
See other posts from Super User
or by edmon
Published on 2011-01-12T21:49:31Z
Indexed on
2011/01/12
21:55 UTC
Read the original article
Hit count: 181
microsoft-access
I have the below code that takes certain fields from my MS Access (A small Hotel Reservation Database)form and populates defined cells in the said Excel file.
Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open("Y:\123files\File\Hotel Reservation.xls")
objXLApp.Application.Visible = True
objXLBook.ActiveSheet.Range("B2") = Me.GuestFirstName & " " & GuestLastName
objXLBook.ActiveSheet.Range("C2") = Me.PhoneNumber
objXLBook.ActiveSheet.Range("E2") = Me.cboCheckInDate
objXLBook.ActiveSheet.Range("F2") = Me.cboCheckOutDate
objXLBook.ActiveSheet.Range("H2") = Me.RoomType
objXLBook.ActiveSheet.Range("I2") = Me.RoomNumber
End Sub
How can I keep populating a new Guest to the same Excel file just on the next row?
© Super User or respective owner