Adding to an existing excell spreadsheet

rendani

New Member
Joined
May 20, 2011
Messages
2
Hi i am having a problem, when i want to add data to an existing/opened spreadsheet in a vb.net program. the thing is i am writing a little program to save data to a spreadsheet until the spreadsheet is full without overwriting anything i have tried to do this for now:

oBook = xlApp.Workbooks.Add
oSheet = oBook.worksheets(1)
oSheet = oBook.activeSheet
oSheet.Range(
"A1").value = lblOrderNumber.Text
oSheet.Range(
"B1").value = lblQuantity.Text
oSheet.Range(
"C1").Value = lblWeight.Text
oSheet.Range(
"D1").Value = "Time _Scanned"
'Format cell dimension
oSheet.columns("A:A").ColumnWidth = 18
oSheet.Columns(
"B:B").ColumnWidth = 30
oSheet.Columns(
"C:C").ColumnWidth = 20
oSheet.Columns(
"D:D").ColumnWidth = 20
'Formating label to cell
oSheet.Range("A1:B1:C1:D1").Font.Bold = True
'Send data from textboxes to cells in excell
oSheet.Range("A2").Value = txtOrderNumber.Text
oSheet.Range(
"B2").Value = txtQuantity.Text
oSheet.Range(
"C2").Value = txtWeight.Text
oSheet.Range(
"D2").Value = TimeOfDay

'Save the workbook and quit Excel problem is here it askes me to overwrite an existing spreadsheet and dont want to do that, i want to keep on adding data please help
oBook.SaveAs(strName, True)
'oBook.Save()
oSheet = Nothing
xlApp.Quit()
xlApp =
Nothing

Thanks a lot
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,519
Messages
6,179,263
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top