halshion
New Member
- Joined
- Jan 9, 2023
- Messages
- 16
- Office Version
- 2013
- Platform
- Windows
Greetings everyone.
I would like to request a bit of help here. I want to encode textbox values input from Sample 1 to Sample 5, based on the value of "Date Encode" and "Time 24 Hour" combobox by linking the combobox values to the values on specific cells. Kindly see
The code below is only for subroutine "OK button", it can only encode texbox values to defined cells, with no conditions. I'll provide any info if you need more.
I would like to request a bit of help here. I want to encode textbox values input from Sample 1 to Sample 5, based on the value of "Date Encode" and "Time 24 Hour" combobox by linking the combobox values to the values on specific cells. Kindly see
The code below is only for subroutine "OK button", it can only encode texbox values to defined cells, with no conditions. I'll provide any info if you need more.
VBA Code:
Private Sub OKButton_Click()
'activate and submit data
Dim wb As Workbook
Dim findrange As Range
Set wb = Workbooks(Machine1.Value & ".xlsx")
wb.Activate
With wb.Sheets(Me.DimensionBox1.Text)
If Len(Data1.Text) > 0 Then .Range("AP16").Value = Data1.Value
If Len(Data2.Text) > 0 Then .Range("AQ16").Value = Data2.Value
If Len(Data3.Text) > 0 Then .Range("AR16").Value = Data3.Value
If Len(Data4.Text) > 0 Then .Range("AS16").Value = Data4.Value
If Len(Data5.Text) > 0 Then .Range("AT16").Value = Data5.Value
End With
wb.Activate
'make workbook visible from machine1_change invisibility
result = MsgBox("Is this ok?", vbOKCancel + vbQuestion)
If result = vbOK Then
wb.Windows(1).Visible = True
wb.Save
wb.Close
'clears textboxes after saving and exit
DateEncode.Clear
Time24hour = ""
DateEncode = ""
DimensionBox1 = ""
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is MSForms.TextBox Then
ctl.Text = ""
End If
Next ctl
Else: MsgBox "Check if all values are correct", vbExclamation
End If
End Sub