VBA Userform (for Entering Data)

Faraei

New Member
Joined
Mar 22, 2014
Messages
2
[h=3]Hello Everybody,[/h] I am a beginner in VBA programming and I have to make a Userform for entering data in the specific places(in a table) in the worksheet. But when I enter a number, it changes all the cells to that number. I can't find my error. I would be appreciated if someone could help me.
I attached my file.
Thanks in advance



Private Sub CommandButton1_Click()
Dim Name As String
Dim Concentration As Integer
Dim Measurment As Integer
Dim Data As Integer

Dim Time As String

Dim IniRow As Integer, IniCol As Integer
Dim Lines(4) As Integer



IniRow = 6
IniCol = 2



Time = ComboBox3.List(ComboBox3.ListIndex)
Concentration = ComboBox2.List(ComboBox2.ListIndex)
Name = ComboBox1.List(ComboBox1.ListIndex)
Measurment = TextBox1.Value



If Name = "Encanto Park Lake" Then
Worksheets("Encanto Park Lake").Activate
If Nutrient = OptionButton1.Value And Concentration = "20" And Time = "First" Then
Lines(1) = Measurment
Else
If Nutrient = OptionButton1.Value And Concentration = "2" And Time = "First" Then
Lines(2) = Measurment

End If
End If
End If



Cells(IniRow, IniCol).Value = Lines(1)
Cells(IniRow, IniCol + 1).Value = Lines(2)
CloseAgrowth

End Sub


Private Sub CommandButton2_Click()
CloseAgrowth
End Sub

Private Sub UserForm_Initialize()



ComboBox3.Clear
ComboBox3.AddItem "First"
ComboBox3.AddItem "Second"
ComboBox3.AddItem "Third"
ComboBox3.AddItem "Fourth"
ComboBox3.AddItem "Fifth"
ComboBox3.ListIndex = 0

ComboBox2.Clear
ComboBox2.AddItem "20"
ComboBox2.AddItem "2"
ComboBox2.AddItem "1"
ComboBox2.AddItem "0.5"
ComboBox2.AddItem "0.2"
ComboBox2.AddItem "0"
ComboBox2.ListIndex = 0

ComboBox1.Clear
ComboBox1.AddItem "Encanto Park Lake"
ComboBox1.AddItem "Rio Salado River"
ComboBox1.ListIndex = 0
TextBox1.Text = 1.352

End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,215,684
Messages
6,126,199
Members
449,298
Latest member
Jest

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