User form command buttons

ValJan

New Member
Joined
Jun 6, 2008
Messages
5
Hi

I'm new to vb but have managed to create a user form to make adding information to a spreadsheet easier. I have a command button named 'Add' and when clicked this automatically updates the worksheet named 'Database'.

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")

End Sub

However, sometimes all the information needed to complete an entry is not available and I would like to be able to save the information I have to a worksheet named 'Draft' so that I can retrieve it later, add the missing information and then save it to the 'Database' worksheet. This sounded simply when I thought about it, but I am now struggling to work out how to do it. I would really appreciate some help, or pointing in the right direction if this has already been dealt with on the forum.

Thanks in advance
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi,

I'd have one command button to have the data stored to the data base and one to store to the drafts sheet when necessary- The code would be the same just replacing the name of the worksheet, infact you could have it on the same button but choose which one when you click the button:

ws = inputbox("Which sheet do you want to save this to?") - Although with this you would obviously have to type the name exactly right unless you design your own msgbox with a combo box on it.

Once it's saved to the drafts recalling it just involves reversing the code. So if you had:

Range("a1").value = txtCustomerName

then to recall it:

txtCustomerName = sheets("Draft").Range("a1").value

which will recall it - do this for all the fields, then the user can amend the data and press the command button you originally had to send it to the database.

I'd suggest assigning a reference to each line so that you can have more than one (use the macro recorder to get the code for 'cells.find... .select' so you can search for the reference and then use activecell.offset to get the rest of the data).

Hope that helps... =D

Arthur =D
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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