shahcu
03-15-2007, 05:22 AM
Hi!
I have created a VB form (Excel VBA) where in when user put a check mark against any check box "TRUE" will get store in excel sheet. I have mentioned the coding in click event. However i am unable to add more than one record.
Code is as follows:
Private Sub CommandButton1_Click()
r = 2
ActiveSheet.Cells(r, 1) = TextBox1.Value
If CheckBox1.Value = True Then
ActiveSheet.Cells(r, 2) = True
Else
ActiveSheet.Cells(r, 2) = False
End If
If CheckBox2.Value = True Then
ActiveSheet.Cells(r, 3) = True
Else
ActiveSheet.Cells(r, 3) = False
End If
If CheckBox3.Value = True Then
ActiveSheet.Cells(r, 4) = True
Else
ActiveSheet.Cells(r, 4) = False
End If
If CheckBox4.Value = True Then
ActiveSheet.Cells(r, 5) = True
Else
ActiveSheet.Cells(r, 5) = False
End If
If CheckBox5.Value = True Then
ActiveSheet.Cells(r, 6) = True
Else
ActiveSheet.Cells(r, 6) = False
End If
If CheckBox6.Value = True Then
ActiveSheet.Cells(r, 7) = True
Else
ActiveSheet.Cells(r, 7) = False
End If
If CheckBox7.Value = True Then
ActiveSheet.Cells(r, 8) = True
Else
ActiveSheet.Cells(r, 8) = False
End If
If CheckBox8.Value = True Then
ActiveSheet.Cells(r, 9) = True
Else
ActiveSheet.Cells(r, 9) = False
End If
'Next r
End Sub
The above code will save one particular transaction ... But i need to save more than one records... Pls help...
I have created a VB form (Excel VBA) where in when user put a check mark against any check box "TRUE" will get store in excel sheet. I have mentioned the coding in click event. However i am unable to add more than one record.
Code is as follows:
Private Sub CommandButton1_Click()
r = 2
ActiveSheet.Cells(r, 1) = TextBox1.Value
If CheckBox1.Value = True Then
ActiveSheet.Cells(r, 2) = True
Else
ActiveSheet.Cells(r, 2) = False
End If
If CheckBox2.Value = True Then
ActiveSheet.Cells(r, 3) = True
Else
ActiveSheet.Cells(r, 3) = False
End If
If CheckBox3.Value = True Then
ActiveSheet.Cells(r, 4) = True
Else
ActiveSheet.Cells(r, 4) = False
End If
If CheckBox4.Value = True Then
ActiveSheet.Cells(r, 5) = True
Else
ActiveSheet.Cells(r, 5) = False
End If
If CheckBox5.Value = True Then
ActiveSheet.Cells(r, 6) = True
Else
ActiveSheet.Cells(r, 6) = False
End If
If CheckBox6.Value = True Then
ActiveSheet.Cells(r, 7) = True
Else
ActiveSheet.Cells(r, 7) = False
End If
If CheckBox7.Value = True Then
ActiveSheet.Cells(r, 8) = True
Else
ActiveSheet.Cells(r, 8) = False
End If
If CheckBox8.Value = True Then
ActiveSheet.Cells(r, 9) = True
Else
ActiveSheet.Cells(r, 9) = False
End If
'Next r
End Sub
The above code will save one particular transaction ... But i need to save more than one records... Pls help...