I have created a vb.net UserForm that feeds data into excel.But the problem is,anytime I enter new data the previous ones get replaced by the new data without any means of retrieval.So my argument is that;I want both the previous and newly entered data displayed on the worksheet.I really need the codes to solve this issue.And also code for displaying the same data i enter on my DataGridView.I have been trying for days and nights but still! Thanks in advance!
Private Sub BtnAddRecord_Click(sender As Object, e As EventArgs) Handles BtnAddRecord.Click
Dim AppExcel As New Excel.Application 'Create a new Excel Application
Dim workbook As Excel.Workbook = AppExcel.Workbooks.Add("C:\Users\DELL\OneDrive\Documents\VbNetFormDone.xlsx") ' 'Create a new workbook
Dim sheet As Excel.Worksheet = workbook.Sheets("Sheet1") ' Create variable a Sheet, Sheet1 must be in WorkBook
AppExcel.Visible = True
AppExcel.DisplayAlerts = False
'Work with range'
Dim AddNew As Range
AddNew = sheet.Range("A65356").End(XlDirection.xlUp).Offset(1, 0)
'Range with text address
AddNew.Offset(0, 0).Value = TextReferenceNo.Text
AddNew.Offset(0, 1).Value = TextFirstname.Text
AddNew.Offset(0, 2).Value = TextSurname.Text
AddNew.Offset(0, 3).Value = TextAddress.Text
AddNew.Offset(0, 4).Value = TextPostalCode.Text
AddNew.Offset(0, 5).Value = TextTelephone.Text
AddNew.Offset(0, 6).Value = TextDateOfReg.Text
AddNew.Offset(0, 7).Value = TextProveOfId.Text
AddNew.Offset(0, 8).Value = TextMemberType.Text
AddNew.Offset(0, 9).Value = TextMemberFees.Text
workbook.SaveAs("C:\Users\DELL\OneDrive\Documents\VbNetFormDone.xlsx", FileFormat:=56) 'Save the workbook
workbook.Close() 'Close workbook
AppExcel.Quit() 'Quit the application