Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing inputted data to closed excel spreadsheet

Status
Not open for further replies.

MrDougJ

Technical User
Feb 25, 2009
8
US
Can anyone help, I am still quite novice and cant solve this problem:
I have writen a VBA where a user inputs data into a form, presses a button, and then the data is inputted into a spreadsheet. I have the code sorted for this with the data being written to a spreadsheet which is part of the same book and can even modify it so that the data is written to another workbook if that book is open (using: "Windows("Book2").Activate" ). What I really need to do is to perform the operations (selecting cells and write the data) in a closed spreadsheet and saving the data.
How can I do this?

The code I have so far, writing the inputted data into a different sheet in the same book is as follows:

Private Sub Enter_Click()

WO = TextBox1.Text
Datein = DateBox.Text
Unit = UnitBox.Text

Sheets("All Records").Rows("5:5").Insert Shift:=xlDown

Sheets("All Records").Range("A5").Value = WO
Sheets("All Records").Range("B5").Value = Datein
Sheets("All Records").Range("C5").Value = Unit

ActiveWorkbook.Save
End Sub

Thanks for your help
 
You have to open the spreadsheet before writing to it, then save and close it.
 
Have you considered using a database table?
You could write the data from Excel to a table without opening it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top