mmn1000
Board Regular
- Joined
- Mar 17, 2020
- Messages
- 76
- Office Version
- 2019
- 2013
- Platform
- Windows
Hello
I'm using the following code
I enter the information in the sheet
In the sheet that I select from the combo box
I have a small problem with this code
Is it possible that with this code, the same sheet will be displayed when selecting the name of the sheet from the Cambodian box on the Excel page?
For this reason, I stated that when I want to perform the registration operation for other sheets, it takes into account the active sheet position in Excel, which is the first sheet, and then registers it in the desired sheet, which causes an error. Please attach the file. Check
I'm using the following code
VBA Code:
Private Sub ComboBox1_Change()
Dim I As Integer
I = Range("D" & Rows.Count).End(xlUp).Row + 1
Me.TextBox1.Text = Cells(I, 2)
Me.TextBox2.Text = Cells(I, 3)
If Cells(I, 4).Value = "P" Then OptionButton4.Value = True Else OptionButton5.Value = True:
End Sub
VBA Code:
Private Sub CommandButton1_Click()
Dim I As Integer
I = Range("D" & Rows.Count).End(xlUp).Row + 1
If TextBox2 <> "" Then
Worksheets(ComboBox1.Value).Select
Worksheets(ComboBox1.Value).Range("E" & I).Value = TextBox4.Value
If OptionButton4.Value = True Then Cells(I, 4) = "P" Else Cells(I, 4) = "O"
MsgBox "The information was successfully recorded", vbMsgBoxRight, "submit information"
Else
MsgBox "Complete the text box", vbMsgBoxRight, "submit information"
End If
I = Range("D" & Rows.Count).End(xlUp).Row + 1
Me.TextBox1.Text = Cells(I, 2)
Me.TextBox2.Text = Cells(I, 3)
End Sub
VBA Code:
Private Sub UserForm_Activate()
' OptionButton1 = True
For I = 1 To Sheets.Count
ComboBox1.AddItem Sheets(I).Name
Next I
End Sub
In the sheet that I select from the combo box
I have a small problem with this code
Is it possible that with this code, the same sheet will be displayed when selecting the name of the sheet from the Cambodian box on the Excel page?
For this reason, I stated that when I want to perform the registration operation for other sheets, it takes into account the active sheet position in Excel, which is the first sheet, and then registers it in the desired sheet, which causes an error. Please attach the file. Check
Last edited by a moderator: