Saving Userform to specified workbook, then saving the workbook and closing

markda2000

New Member
Joined
Mar 24, 2011
Messages
9
Hi,

I have a userform that saves saves data to a separate specified workbook
However I have a number of issues with this.
Firstly the specified workbook open and I wish it to be hidden from the user.
also I cannot get the workbook to save once the data has copied from the userform.
And lastly the Userform clears itself but then cannot have data re-entered, I believe this is due to the the focus being on the workbook that the data is being saved still being open.

here is my code so far

Code:
Private Sub Submit_Click()
Dim notestosendtoclipboard As String
Dim textobj As DataObject
Set textobj = New DataObject

 TextBoxNotes.Value
textobj.SetText notestosendtoclipboard
textobj.PutInClipboard


MsgBox "Thank you for your submission " & vbNewLine & "You can now press CRTL V to copy your notes " & vbNewLine  & TextBoxNotes.Value


Dim iRow As Long
Dim wb As Workbook
Dim ws As Worksheet

    
    
    Set wb = Workbooks.Open(Filename:="U:\copieddata.xlsx")
    Set ws = wb.Worksheets("sheet1")
    
    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'copy the data to the database
    ws.Cells(iRow, 1).Value = Now
    ws.Cells(iRow, 2).Value = fOSUserName
    ws.Cells(iRow, 19).Value = Me.TextBoxNotes.Value
    
    
     



Unload form
form.Show
End Sub

This is my first VBA project and as you can probably tell have only very basic understanding of what i am doing.

Any help will be greatly appreciated.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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