Good day,
I have a userform that has a start and end date in it and then three checkBoxes (1st, 2nd and repeat) I have managed to get the first and second section working fine, however part three has me at the end.
In 1st and 2nd it just has to get the info from two columns (the first time and the second time) then will paste then name of the person and there amounts - I like the fact that it gives me the amounts and from the names i can just do a counta to see how many came in a period of time.
Section three needs to get data from columns bc,cf,bi,bl and so on right through to col op these col are where the dates are in.
I will paste the code below and really hope that somebody would be able to help me on getting onto the right path - many thx
I have a userform that has a start and end date in it and then three checkBoxes (1st, 2nd and repeat) I have managed to get the first and second section working fine, however part three has me at the end.
In 1st and 2nd it just has to get the info from two columns (the first time and the second time) then will paste then name of the person and there amounts - I like the fact that it gives me the amounts and from the names i can just do a counta to see how many came in a period of time.
Section three needs to get data from columns bc,cf,bi,bl and so on right through to col op these col are where the dates are in.
I will paste the code below and really hope that somebody would be able to help me on getting onto the right path - many thx
Code:
Private Sub cmbsubmit_Click()
Dim FINALROW As Long
Dim i As Long
Dim SDATE As Date
Dim EDATE As Date
SDATE = tbStDate
EDATE = tbEndDate
Sheets("NO OF VISITS").Range("a2:h2000").ClearContents
FINALROW = Worksheets("PATIENT DATA").Range("aw2000").End(xlUp).Row
For i = 3 To FINALROW
If CheckBox1.Value = True Then
If Worksheets("PATIENT DATA").Cells(i, "aw") >= SDATE Then
If Worksheets("PATIENT DATA").Cells(i, "aw") <= EDATE Then
With Worksheets("PATIENT DATA")
.Range(.Cells(i, "a"), .Cells(i, "a")).Copy
End With
Worksheets("NO OF VISITS").Range("A2000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValuesAndNumberFormats
With Worksheets("PATIENT DATA")
.Range(.Cells(i, "ay"), .Cells(i, "ay")).Copy
End With
Worksheets("NO OF VISITS").Range("b2000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValuesAndNumberFormats
End If
End If
End If
Next i
FINALROW = Worksheets("PATIENT DATA").Range("az2000").End(xlUp).Row
For i = 3 To FINALROW
If CheckBox2.Value = True Then
If Worksheets("PATIENT DATA").Cells(i, "az") >= SDATE Then
If Worksheets("PATIENT DATA").Cells(i, "az") <= EDATE Then
With Worksheets("PATIENT DATA")
.Range(.Cells(i, "a"), .Cells(i, "a")).Copy
End With
Worksheets("NO OF VISITS").Range("c2000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValuesAndNumberFormats
With Worksheets("PATIENT DATA")
.Range(.Cells(i, "bb"), .Cells(i, "bb")).Copy
End With
Worksheets("NO OF VISITS").Range("d2000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValuesAndNumberFormats
End If
End If
End If
Next i
FINALROW = Worksheets("PATIENT DATA").Range("bc3:or2000").End(xlUp).Row
For i = 3 To FINALROW
If CheckBox3.Value = True Then
If Worksheets("PATIENT DATA").Cells(i, "bc3:or2000") >= SDATE Then
If Worksheets("PATIENT DATA").Cells(i, "bc3:or2000") <= EDATE Then
With Worksheets("PATIENT DATA")
.Range(.Cells(i, "a"), .Cells(i, "a")).Copy
End With
Worksheets("NO OF VISITS").Range("e2000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValuesAndNumberFormats
End If
End If
End If
Next i
Application.CutCopyMode = False
'Worksheets(ActiveSheet.Index - 8).Select
End Sub