Hi,
I have a userform, which currently works partially as needed (I have included the code for the form below)
I need the form to also perform another task, I need it to send data to one more worksheet within the workbook.
I am unsure how to handle this in the code to ensure information goes to both worksheets. I also need the information for the additional worksheet to be ADDED to a particular cell based on the information provided in the form.
What I need:
1. I need the Value from "txtAmt" to be entered in a specific cell on different worksheet ("TR Data")
2. the specific cell needs to be in the same row as the number selected as value for "cboTR", specific cell would be in column H of that row
3. In a perfect world, I would like it added as a formula to the current amount in column H, but will settle for net result of adding the value to the current value in that cell
I will also need to execute the protect and unprotect on "TR Data" worksheet the same as being done on "TR Increase Log"
Any help advice is greatly appreciated!
I have a userform, which currently works partially as needed (I have included the code for the form below)
I need the form to also perform another task, I need it to send data to one more worksheet within the workbook.
I am unsure how to handle this in the code to ensure information goes to both worksheets. I also need the information for the additional worksheet to be ADDED to a particular cell based on the information provided in the form.
What I need:
1. I need the Value from "txtAmt" to be entered in a specific cell on different worksheet ("TR Data")
2. the specific cell needs to be in the same row as the number selected as value for "cboTR", specific cell would be in column H of that row
3. In a perfect world, I would like it added as a formula to the current amount in column H, but will settle for net result of adding the value to the current value in that cell
I will also need to execute the protect and unprotect on "TR Data" worksheet the same as being done on "TR Increase Log"
Any help advice is greatly appreciated!
Code:
Private Sub cmbTR_Change()
End Sub
Private Sub cmdAddIncr_Click()
Dim iRow as Long
Dim ws as Worksheet
Set ws = Worksheets ("TR Increase Log")
'find first empty row in database
iRow = ws.cells(Rows.Count,1) _
.end(xlUp).Offset(1,0).Row
'unprotect sheet
ws.Unprotect "XXX"
'remind completing TR number
IF Trim(Me.cboTR.Value) = "" then
ME.cboTR.SetFocus
msgBox "Enter TR Number!!"
Exit Sub
End If
'copy the data to the log
ws.cells (iRow, 1).Value = Me.cboTR.Value
ws.cells (iRow, 2).Value = Me.TxtDate.Value
ws.cells (iRow, 3).Value = Me.txtAmt.Value
ws.cells (iRow, 4).Value = Me.txtBA.Value
ws.cells (iRow, 5).Value = Me.txtcomment.Value
Me.cboTR.SetFocus
'clear data
Me.cboTR.Value = ""
'protect sheet
ws.Protect "XXX"
End Sub
Private Sub Cmd2_Click()
Unload Me
End Sub
Private Sub Userform_Initialize()
Dim CTR As Range
Dim ws as Worksheet
Set ws = Worksheets ("TR Data")
For Each cTR In ws.Range ("TR_Number")
With ME.cboTR
.AddItem cTR.Value
End With
Next cTR
Me.TxtDate.Value = Format(Date, "Medium Date")
Me.sboTR.SetFocus
End Sub