Hi i am trying to write the contents of textboxes to a spreadsheet. The code i have does work but at the moment i have to specify what cells to write to. What i would like is for the text to get written to a different row each time but i do not know how to increment the row each time if there is text already in a cell. Any help would be greatly appreciated.
Dim xlApp As Microsoft.Office.Interop.Excel.Application Dim xlBook As Microsoft.Office.Interop.Excel.Workbook Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet xlApp = GetObject("", "Excel.Application") xlBook = xlApp.Workbooks.Open("D:\VBtest\test.xlsx") xlSheet = xlBook.Worksheets("Sheet1") xlApp.Visible = True xlSheet.Cells(1, 1).Value = TextBox1.Text xlSheet.Cells(1, 2).Value = TextBox2.Text xlBook.Save() xlBook.Close(False) xlApp.Quit() End Sub