Nov 07 2019 08:26 AM
Hello,
I'm new to VBA and have used the search function within the community to try to find a similar issue but so far i'm yet to find a solution.
I have a Userform that has multiple textbox's. On private sub cbsave_click of a command button I want to send the data from my userFform to a new line on multiple different sheets in my workbook.
So far I have only been able to submit my data to only one sheet. Here is the code I have to complete this:
Private Sub cbsave_Click()
carryon = MsgBox("Confirm data entered is correct", vbYesNo, "Confirm")
If carryon = vbYes Then
Dim wks As Worksheet
Dim addnew As Range
Set wks = Sheet6
Set addnew = wks.Range("A1048576").End(xlUp).Offset(1, 0)
addnew.Offset(0, 0).Value = logdate.Text
addnew.Offset(0, 1).Value = cbobuilding
addnew.Offset(0, 2).Value = cbodepartment
addnew.Offset(0, 3).Value = cbomachine
addnew.Offset(0, 4).Value = txtfault.Text
addnew.Offset(0, 5).Value = txtrepair.Text
addnew.Offset(0, 6).Value = cboname
addnew.Offset(0, 7).Value = cboCause
addnew.Offset(0, 8).Value = txtstartdate.Text
addnew.Offset(0, 9).Value = txtstarttime.Text
addnew.Offset(0, 10).Value = txtenddate.Text
addnew.Offset(0, 11).Value = txtendtime.Text
addnew.Offset(0, 12).Value = txtdowntime.Text
End If
Unload Me
The code above will add the information onto sheet6. However I have more text boxes that I would like to send to sheet7 through the same _click for example.
Any help would be greatly appreciated!
Thanks,
Matt
Nov 07 2019 12:36 PM
Solution@MattBreeze Why not just repeat your Set statements and change the wks reference to sheet 7? Then duplicate what you've already got with the other text boxes and put it before the End If line.
Nov 08 2019 12:44 AM
Nov 07 2019 12:36 PM
Solution@MattBreeze Why not just repeat your Set statements and change the wks reference to sheet 7? Then duplicate what you've already got with the other text boxes and put it before the End If line.