Hello There!
I need to save data and search for it through different worksheets in a work book via User Form. Data has to be saved depending on what section it belongs to
Each section's name (selected From a Combo Box ) would have a respective worksheet. When searching for data It should pulled out straight to the User Form.
Any Help on this issue would be much appreciated, as I tried and it does not work. Please see below the code I made for saving data:
I need to save data and search for it through different worksheets in a work book via User Form. Data has to be saved depending on what section it belongs to
Each section's name (selected From a Combo Box ) would have a respective worksheet. When searching for data It should pulled out straight to the User Form.
Any Help on this issue would be much appreciated, as I tried and it does not work. Please see below the code I made for saving data:
VBA Code:
Sub cmdSave_Click()
Dim shBox As Worksheet
Dim iCurrentRow As Integer
Dim sBoxName As String
sBoxName = CLng(Control7.SelectedItem) 'Control7" (Combo Box to select the section)
Set shBox = ThisWorkbook.Sheets(sBoxName)
iCurrentRow = shBox.Range("A" & Application.Rows.Count).End(xlUp).Row + 1
With shBox
.Cells(iCurrentRow, 1) = iCurrentRow - 1
.Cells(iCurrentRow, 3) = Control2.Text
.Cells(iCurrentRow, 4) = Control3.Text
.Cells(iCurrentRow, 5) = Control4.Text
.Cells(iCurrentRow, 6) = Control5.Text
.Cells(iCurrentRow, 7) = Control6.Text
.Cells(iCurrentRow, 8) = Control7.Text
.Cells(iCurrentRow, 9) = Control8.Text
.Cells(iCurrentRow, 10) = Control9.Text
.Cells(iCurrentRow, 11) = Control10.Text
.Cells(iCurrentRow, 12) = Control11.Text
.Cells(iCurrentRow, 13) = Control12.Text
.Cells(iCurrentRow, 14) = Control13.Text
.Cells(iCurrentRow, 15) = Control14.Text
.Cells(iCurrentRow, 16) = Control15.Text
.Cells(iCurrentRow, 17) = Control16.Text
.Cells(iCurrentRow, 18) = Control17.Text
.Cells(iCurrentRow, 19) = Control18.Text
End With
MsgBox "Data added succesfully!"
End Sub
[ATTACH type="full"]112262[/ATTACH]