how to use userform

dharsana

Board Regular
Joined
Sep 7, 2002
Messages
58
I am new to excel and using excel2002.I would like to know how to use a userform for entering data and save it automatically.i.e when I open the workbook ,userform pops-up for adding data which is added to sheet3(or any other sheet).If I close the userform ,I should be able to work normal.

thank you in advance
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
On 2002-09-08 06:47, dharsana wrote:...I would like to know how to use a userform for entering data and save it automatically.i.e when I open the workbook ,userform pops-up for adding data ....

In the Workbook_Open routine,found in ThisWorkbook there will be at least one line of code:
Userform1.Show
Userform1 is the default name for the first userform you create. You may/can change it's name to something else if you desire.

I suggest that all the code specific to the userform be kept in the userform module. If you want the current date displayed, the last line of the workbook displayed, etc. that sort of code will go in the Userform_Initialize routine. That way, when you are designing the form and want to see how it behaves, all you do is press F5 to display it.


...which is added to sheet3(or any other sheet)...

More detail is needed. Are we speaking of fixed cells, or adding data to the first open line at the end of a list?

If you need to add data at the end of a column, one technique is to select a cell at the extreme end of the column and 'come up' to the first cell filled with data, then move down one cell.

Start the Macro Recorder, and record the code for End-UpArrowKey combinations.

Cells(65000,1).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1,0).Select


Is the sanitized code for the keystrokes (when in relative reference) to find your way to the end of a column.

If I close the userform ,I should be able to work normal.

If you want a Cancel button, set it's .Cancel property set to True, and it's CancelButton_Click routine to include Unload Me. Suggest you change it's codename from CommandButton1, giving you a CancelButton_Click routine.


As to when your data gets plugged into the sheet, a lot depends on your application. If you want to wait until the user presses a Done button, the DoneButton_Click routine will have the code, or call the code.

If you desire a "Are you sure you want to exit?" message, then call that MsgBox in UserForm_Terminate routine.
This message was edited by stevebausch on 2002-09-08 08:29
 
Upvote 0

Forum statistics

Threads
1,224,247
Messages
6,177,406
Members
452,774
Latest member
Macca1962

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