Hello everyone,
I'm just starting out using VBA, I want to make a fillible form for work. With some (a lot ) help from videos a managed to write this code, it works and fill everything correct, but one thing a need that if in "Projekt." box there is a selected value, than all the filled information would go to a specific sheet. Could someone help with this problem?
And I would really appreciate if someone could give my some pointers or guide/links how to become better on VBA.
Thank you.
Sub Reset()
Dim iRow As Long
iRow = [counta(Database1!A:A)] 'identifying the last row
With UserForm1
.Moduliai.Clear
.Mo.AddItem ""
.Mo.AddItem ""
.Mo.AddItem ""
.Mo.AddItem ""
.Mod.Clear
.Mod.AddItem ""
.Mod.AddItem ""
.Mod.AddItem ""
.PU.Clear
.PU.AddItem ""
.PU.AddItem ""
.PU.AddItem ""
.PU.AddItem ""
.Fs.Clear
.Fs.AddItem ""
.Fs.AddItem ""
.Fs.AddItem ""
.Fs.AddItem ""
.Aksi.Clear
.Aksai.AddItem ""
.Aksi.AddItem ""
.Aksi.AddItem ""
.Akse1.Clear
.Akse.AddItem ""
.Akse.AddItem ""
.Akse.AddItem ""
.Pas.Value = ""
.Past2.Value = ""
.Projekt.Clear
.Projekt.AddItem ""
.Projekt.AddItem ""
.Projekt.AddItem ""
.Projekt.AddItem ""
.Databaselist.ColumnCount = 9
.Databaselist.ColumnHeads = True
If iRow > 1 Then
.Databaselist.RowSource = "Database1!A2:I" & iRow
Else
.Databaselist.RowSource = "Database1!A2:I2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database1")
iRow = [counta(Database1!A:A)] + 1
With sh
.Cells(iRow, 1) = UserForm1.M.Value
.Cells(iRow, 2) = UserForm1.Mo.Value
.Cells(iRow, 3) = UserForm1.Ps.Value
.Cells(iRow, 4) = UserForm1.Fs.Value
.Cells(iRow, 5) = UserForm1.Aks.Value
.Cells(iRow, 6) = UserForm1.Aks.Value
.Cells(iRow, 7) = UserForm1.P.Value
.Cells(iRow, 8) = UserForm1.Pa.Value
End With
End Sub
Sub Show_Form()
UserForm1.Show
End Sub
I'm just starting out using VBA, I want to make a fillible form for work. With some (a lot ) help from videos a managed to write this code, it works and fill everything correct, but one thing a need that if in "Projekt." box there is a selected value, than all the filled information would go to a specific sheet. Could someone help with this problem?
And I would really appreciate if someone could give my some pointers or guide/links how to become better on VBA.
Thank you.
Sub Reset()
Dim iRow As Long
iRow = [counta(Database1!A:A)] 'identifying the last row
With UserForm1
.Moduliai.Clear
.Mo.AddItem ""
.Mo.AddItem ""
.Mo.AddItem ""
.Mo.AddItem ""
.Mod.Clear
.Mod.AddItem ""
.Mod.AddItem ""
.Mod.AddItem ""
.PU.Clear
.PU.AddItem ""
.PU.AddItem ""
.PU.AddItem ""
.PU.AddItem ""
.Fs.Clear
.Fs.AddItem ""
.Fs.AddItem ""
.Fs.AddItem ""
.Fs.AddItem ""
.Aksi.Clear
.Aksai.AddItem ""
.Aksi.AddItem ""
.Aksi.AddItem ""
.Akse1.Clear
.Akse.AddItem ""
.Akse.AddItem ""
.Akse.AddItem ""
.Pas.Value = ""
.Past2.Value = ""
.Projekt.Clear
.Projekt.AddItem ""
.Projekt.AddItem ""
.Projekt.AddItem ""
.Projekt.AddItem ""
.Databaselist.ColumnCount = 9
.Databaselist.ColumnHeads = True
If iRow > 1 Then
.Databaselist.RowSource = "Database1!A2:I" & iRow
Else
.Databaselist.RowSource = "Database1!A2:I2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database1")
iRow = [counta(Database1!A:A)] + 1
With sh
.Cells(iRow, 1) = UserForm1.M.Value
.Cells(iRow, 2) = UserForm1.Mo.Value
.Cells(iRow, 3) = UserForm1.Ps.Value
.Cells(iRow, 4) = UserForm1.Fs.Value
.Cells(iRow, 5) = UserForm1.Aks.Value
.Cells(iRow, 6) = UserForm1.Aks.Value
.Cells(iRow, 7) = UserForm1.P.Value
.Cells(iRow, 8) = UserForm1.Pa.Value
End With
End Sub
Sub Show_Form()
UserForm1.Show
End Sub