Finding data from one spreadsheet and pasting it to another

quintin

Board Regular
Joined
Jun 26, 2013
Messages
52
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
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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,214,790
Messages
6,121,608
Members
449,038
Latest member
apwr

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