vba program clarification

S

sarasa

how to do increment so that each records store in different cell.

Set LastRow = Sheet1.Range("a65536").End(xlUp)
Set LastRow = Sheet1.Range("b65536").End(xlUp) so on...
and in this code i insert scroll bar. code how to do that.
could you explain to me




Private Sub CommandButton1_Click()

Dim LastRow As Object

Set LastRow = Sheet1.Range("a65536").End(xlUp)
If OptionButton1.Value = True Then
LastRow.Offset(1, 1).Value = "Question 1. " + OptionButton1.Caption
ElseIf OptionButton2.Value = True Then
LastRow.Offset(1, 1).Value = "Question 1. " + OptionButton2.Caption
ElseIf OptionButton3.Value = True Then
LastRow.Offset(1, 1).Value = "Question 1. " + OptionButton3.Caption
End If



If OptionButton4.Value = True Then
LastRow.Offset(2, 1).Value = "Question 2. " + OptionButton4.Caption
ElseIf OptionButton5.Value = True Then
LastRow.Offset(2, 1).Value = "Question 2. " + OptionButton5.Caption
ElseIf OptionButton6.Value = True Then
LastRow.Offset(2, 1).Value = "Question 2. " + OptionButton6.Caption
End If
If OptionButton7.Value = True Then
LastRow.Offset(3, 1).Value = "Question 3. " + OptionButton7.Caption
ElseIf OptionButton8.Value = True Then
LastRow.Offset(3, 1).Value = "Question 3. " + OptionButton8.Caption
ElseIf OptionButton9.Value = True Then
LastRow.Offset(3, 1).Value = "Question 3. " + OptionButton9.Caption
ElseIf OptionButton10.Value = True Then
LastRow.Offset(3, 1).Value = "Question 3. " + OptionButton10.Caption
ElseIf OptionButton11.Value = True Then
LastRow.Offset(3, 1).Value = "Question 3. Other"
LastRow.Offset(3, 3).Value = TextBox1.Text + " Months"

End If

If OptionButton11.Value = False Then
LastRow.Offset(3, 3).Value = " "
End If

LastRow.Offset(4, 1).Value = "Question 4. " + TextBox2.Text
LastRow.Offset(4, 2).Value = "Physician: "
LastRow.Offset(4, 3).Value = " " + TextBox2.Text

LastRow.Offset(5, 2).Value = " NP/RN: "
LastRow.Offset(5, 3).Value = " " + TextBox3.Text

LastRow.Offset(6, 2).Value = " Other: "
LastRow.Offset(6, 3).Value = " " + TextBox4.Text

LastRow.Offset(7, 2).Value = " Total: "
LastRow.Offset(7, 3).Value = " " + TextBox5.Text

LastRow.Offset(4, 5).Value = " Salary: "
LastRow.Offset(4, 5).Value = " " + TextBox6.Text

LastRow.Offset(5, 4).Value = "Operational: "
LastRow.Offset(5, 5).Value = " " + TextBox7.Text

LastRow.Offset(6, 4).Value = " Capital: "
LastRow.Offset(6, 5).Value = " " + TextBox8.Text

LastRow.Offset(7, 4).Value = " Total: "
LastRow.Offset(7, 5).Value = " " + TextBox9.Text



LastRow.Offset(8, 1).Value = "Question 5. " + TextBox10.Text

End Sub


Private Sub CommandButton2_Click()
End

End Sub

Private Sub CommandButton3_Click()

TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
TextBox5.Text = " "
TextBox6.Text = " "
TextBox7.Text = " "
TextBox8.Text = " "
TextBox9.Text = " "
TextBox10.Text = " "
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
OptionButton4.Value = False
OptionButton5.Value = False
OptionButton6.Value = False
OptionButton7.Value = False
OptionButton8.Value = False
OptionButton9.Value = False
OptionButton10.Value = False
OptionButton11.Value = False

End Sub

Private Sub Frame5_Click()

End Sub

Private Sub Label4_Click()

End Sub

Private Sub Label5_Click()

End Sub

Private Sub UserForm_Click()

End Su
 
D

David Adamson

I am assuming that you are creating a database to add, edit, delete and
manage data.

I would strongly suggest to do a search on databases (or datasets from a
userform) at google as there is some great stuff with examples already
explained.

Failing that John Walkenbach's dataform
http://j-walk.com/ss/dataform/download.htm is very good and would slove the
bulk of your problems
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top