ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using forms to store data (https://www.excelbanter.com/excel-programming/346341-using-forms-store-data.html)

oscarooko[_10_]

Using forms to store data
 

I have a form with the folowing text input fields;
IDNumber
Name
Phone

How do I store the data that I input using the form into an excel
spreadsheet? or Must I use an access database for the same?


--
oscarooko
------------------------------------------------------------------------
oscarooko's Profile: http://www.excelforum.com/member.php...o&userid=28116
View this thread: http://www.excelforum.com/showthread...hreadid=487407


dominicb[_169_]

Using forms to store data
 

Good morning oscarooko

The userform is only a "front end", the data can be stored in a normal
worksheet, but must be written to the worksheet with the userform.

Your information is a bit sparse so I can't give you much specific
guidance, but say you have a button on your form, something lke this
would write the contents of textbox1 to the currently active cell on
the worksheet.

ActiveCell.Value = TextBox1.Value

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=487407


Francis Brown

Using forms to store data
 
Hello

I think the following will work.

notes-
correct path to file
assumes code in diffrent workbook to data
data book called Data.xls
rename say sheet1 to data and add headings per your question in a1, b1 and c1
The code is attached to a command button on your user form.

Private Sub CommandButton1_Click()

Do Until issave = True
Dim theBk As Workbook
Set theBk = Workbooks.Open("C:\yourfolder\Data.xls")
If theBk.ReadOnly Then
theBk.Close False
issave = False
Else
newrow =_
Workbooks("Data.xls").Sheets("data").Range("A65536 ").End(xlUp).Row + 1
Workbooks("Data.xls").Sheets("data").Cells(newrow, 1).Value_
= TextBox1.Value
Workbooks("Data.xls").Sheets("data").Cells(newrow, 2).Value_
= TextBox2.Value
Workbooks("Data.xls").Sheets("data").Cells(newrow, 3).Value_
= TextBox3.Value

theBk.Close True
MsgBox "Records Saved"
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
issave = True

End If
Loop

End Sub

--
Regards and Thanks for any assistance.

Francis Brown.


"oscarooko" wrote:


I have a form with the folowing text input fields;
IDNumber
Name
Phone

How do I store the data that I input using the form into an excel
spreadsheet? or Must I use an access database for the same?


--
oscarooko
------------------------------------------------------------------------
oscarooko's Profile: http://www.excelforum.com/member.php...o&userid=28116
View this thread: http://www.excelforum.com/showthread...hreadid=487407



Francis Brown

Using forms to store data
 
I should also add that my code was developed for multiple users to add data
via a form and it save into a file on a network drive. Hence the while until
loop to test for the file being read/write available and only doing the save
while it could do so.
--
Regards

Francis Brown.


"Francis Brown" wrote:

Hello

I think the following will work.

notes-
correct path to file
assumes code in diffrent workbook to data
data book called Data.xls
rename say sheet1 to data and add headings per your question in a1, b1 and c1
The code is attached to a command button on your user form.

Private Sub CommandButton1_Click()

Do Until issave = True
Dim theBk As Workbook
Set theBk = Workbooks.Open("C:\yourfolder\Data.xls")
If theBk.ReadOnly Then
theBk.Close False
issave = False
Else
newrow =_
Workbooks("Data.xls").Sheets("data").Range("A65536 ").End(xlUp).Row + 1
Workbooks("Data.xls").Sheets("data").Cells(newrow, 1).Value_
= TextBox1.Value
Workbooks("Data.xls").Sheets("data").Cells(newrow, 2).Value_
= TextBox2.Value
Workbooks("Data.xls").Sheets("data").Cells(newrow, 3).Value_
= TextBox3.Value

theBk.Close True
MsgBox "Records Saved"
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
issave = True

End If
Loop

End Sub

--
Regards and Thanks for any assistance.

Francis Brown.


"oscarooko" wrote:


I have a form with the folowing text input fields;
IDNumber
Name
Phone

How do I store the data that I input using the form into an excel
spreadsheet? or Must I use an access database for the same?


--
oscarooko
------------------------------------------------------------------------
oscarooko's Profile: http://www.excelforum.com/member.php...o&userid=28116
View this thread: http://www.excelforum.com/showthread...hreadid=487407




All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com