chidung2009
Thành viên hoạt động
- Tham gia
- 12/9/12
- Bài viết
- 123
- Được thích
- 8
Mình có một form chứa rất nhiều checkbox.
Khi bấm chọn checkBox = True và lưu thì ghi lên Sheet từ A4 đến F4
Mỗi khi mở form thì sẽ load dữ liệu lên form CheckBox đã chọn hay chưa.
Mình đã cố gắng viết hàm lặp nhưng đều thất bại, mong ACE giúp mình với
Mình xin trân trọng cảm ơn
Khi bấm chọn checkBox = True và lưu thì ghi lên Sheet từ A4 đến F4
Mỗi khi mở form thì sẽ load dữ liệu lên form CheckBox đã chọn hay chưa.
Mình đã cố gắng viết hàm lặp nhưng đều thất bại, mong ACE giúp mình với
Mình xin trân trọng cảm ơn
Mã:
Private Sub cbSave_Click()
'Dim i As Integer
'Dim j As Integer
'For i = 1 To 5 'Biên de chay CheckBox1
'For j = 1 To 6 ' Bien de chay cot
'If "CheckBox" & i.Value = True Then
' Rows(j, 4) = True
'Else: Rows(j, 4) = False
'Next j
'Next i
'---------------
If CheckBox1.Value = True Then
Range("A4").Select
ActiveCell.FormulaR1C1 = True
Else
Range("A4").Select
ActiveCell.FormulaR1C1 = False
End If
If CheckBox2.Value = True Then
Range("B4").Select
ActiveCell.FormulaR1C1 = True
Else
Range("B4").Select
ActiveCell.FormulaR1C1 = False
End If
If CheckBox3.Value = True Then
Range("C4").Select
ActiveCell.FormulaR1C1 = True
Else
Range("C4").Select
ActiveCell.FormulaR1C1 = False
End If
If CheckBox4.Value = True Then
Range("D4").Select
ActiveCell.FormulaR1C1 = True
Else
Range("D4").Select
ActiveCell.FormulaR1C1 = False
End If
If CheckBox5.Value = True Then
Range("E4").Select
ActiveCell.FormulaR1C1 = True
Else
Range("E4").Select
ActiveCell.FormulaR1C1 = False
End If
If CheckBox6.Value = True Then
Range("F4").Select
ActiveCell.FormulaR1C1 = True
Else
Range("F4").Select
ActiveCell.FormulaR1C1 = False
End If
Unload Me
End Sub
File đính kèm
Lần chỉnh sửa cuối: