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
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.
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.