send userform data to another workbook

rlkam

New Member
Joined
Feb 25, 2018
Messages
1
[FONT=&quot]I have a userform that collects customer information and generates a receipt. Presently the receipt is generated in another tab within the same workbook. Each time the userform is used the receipt is over written.[/FONT]
[FONT=&quot]I would like to have the receipt put into another workbook and each receipt is put in a new tab at the end. So, if the form is run 10 times the other workbook has 10 tabs each containing a different receipt.[/FONT]
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
user clicks save button, which runs: MakeReciept

Code:
Public Sub MakeReceipt()
Dim vName, vAddr, vAmt


   'get data from form
vName = txtName
vAddr = txtAddr
vAmt = txtAmtPd


  'post data to target wb
Workbooks.Open "c:\folder\receipts.xls"
Sheets.Add
Range("A1").Value = "Date"
Range("B1").Value = Date
Range("A2").Value = "Name"
Range("B2").Value = vName
Range("A3").Value = "Address"
Range("B3").Value = vAddr
Range("A4").Value = "Amt Paid"
Range("B4").Value = vAmt


ActiveWorkbook.Close True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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