Need help with VBA - just starting out

david1013

New Member
Joined
Jun 3, 2022
Messages
1
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
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
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top