maverick0106 0 Newbie Poster

Hi,

I'm building an application that tracks certain information of my customers so that I can keep it all in order and in one place

so I'm pretty much done however I'm trying to populate the excel sheet, but I'm not too sure how to add new customers without deleting the old one... I know I might be needing a for loop but I'm not too sure how to implement it. the code that I have is as follows:

oXL = CreateObject("Excel.Application")
            oXL.Workbooks.Open(fName)
            oXL.Visible = True

            'Get the Workbook. or add a workbook (Commented out)
            'oWB = oXL.Workbooks.Add
            oWB = oXL.ActiveWorkbook
            oSheet = oWB.ActiveSheet

            'Add table headers going cell by cell.

            oSheet.Cells(1, 1).value = "First Name"
            oSheet.Cells(1, 2).value = "Last Name"
            oSheet.Cells(1, 3).value = "Address"
            oSheet.Cells(1, 4).value = "Postal Code"
            oSheet.Cells(1, 5).value = "City"
            oSheet.Cells(1, 6).value = "Province"
            oSheet.Cells(1, 7).value = "Home Phone"
            oSheet.Cells(1, 8).value = "Cell Phone"
            oSheet.Cells(1, 9).value = "Delivery Date"
            oSheet.Cells(1, 10).value = "Purchase Date"
            oSheet.Cells(1, 11).value = "Order Number"
            oSheet.Cells(1, 12).value = "SKU's"


            'Format cells as bold, vertical alignment = center
            With oSheet.Range("A1", "L1")

                .Font.Bold = True
                .VerticalAlignment = Excel.XlVAlign.xlVAlignCenter

            End With

            'Fill in the cells with the information from the TextBox's
            'Code here what needs to be coded




            'Autofit columns A:L
            oRng = oSheet.Range("A1", "L1")
            oRng.EntireColumn.AutoFit()

            'Make sure that Excel is visible and give user control of lifetime
            oXL.Visible = True
            oXL.UserControl = True

            'Release object references.
            oRng = Nothing
            oSheet = Nothing
            oXL.ActiveWorkbook.Save()
            oXL.ActiveWorkbook.Close(False)
            oXL.DisplayAlerts = True
            oXL.Quit()
            oXL = Nothing

so its pretty much done and working, but I don't really know how to add new people...

obviously I don't want to add them one by one by code, since that's not really too simple... also, my application gets the information from textboxes from the form, and is supposed to populate the cells with that information...

I'm trying to avoid putting: osheet.cells(2, 1).value = Textbox1.text because that way I would have to put waaaay too many of these... so is there a way I can find the end of the file and continue adding from there???

Thank you sooooo much in advance for any and all help!!
I'm hoping to get this done ASAP before my next shift :) I want to impress people :)


Once again thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.