Hi All,
I need a help regarding the below issue which i'm facing while automating our bill issue system.
I have an excel sheet where the tasks done by multiple users is tracked. The tasks are categorized into two types Critical and Non Critical. At the end of month a random Check is made in the total work done by each user. That report is generated from the system automatically. From this we need to pick the specified number of bills done by each user in both critical and non critical categories and paste the data in separate sheets. This is a time taking process as the number of users are more.
I got the code (from other source) that pulls the specified number of records from the total records user wise and paste it in a different sheet (i.e critical in Critical Sheet and Non Critical in Non Critical sheet). However, The sample is being picked from the top only . I just want to know if code can be edited in such a way that the sample would be picked randomly instead of picking only from TOP.
Below is the code which i'm using
Thanks in Advance
I need a help regarding the below issue which i'm facing while automating our bill issue system.
I have an excel sheet where the tasks done by multiple users is tracked. The tasks are categorized into two types Critical and Non Critical. At the end of month a random Check is made in the total work done by each user. That report is generated from the system automatically. From this we need to pick the specified number of bills done by each user in both critical and non critical categories and paste the data in separate sheets. This is a time taking process as the number of users are more.
I got the code (from other source) that pulls the specified number of records from the total records user wise and paste it in a different sheet (i.e critical in Critical Sheet and Non Critical in Non Critical sheet). However, The sample is being picked from the top only . I just want to know if code can be edited in such a way that the sample would be picked randomly instead of picking only from TOP.
Below is the code which i'm using
Thanks in Advance
Code:
Sub ef()
Dim i&, x&, y&, user As Range, ws1 As Worksheet, ws2 As Worksheet
With Sheets("main")
For Each user In .Range("B2:B" & .Cells(Rows.Count, "B").End(xlUp).Row)
If Not .Range("L" & user.Row) = 0 Then
Set ws1 = Sheets("CRTC")
Set ws2 = Sheets("CRTC Smpl")
For i = 1 To .Range("L" & user.Row)
y = x
On Error Resume Next
x = x + WorksheetFunction.Match(user, ws1.Range("L" & x + 1 & ":L" & ws1.Cells(Rows.Count, "L").End(xlUp).Row), 0)
On Error GoTo 0
If y = x Then Exit For
ws1.Rows(x).Copy Destination:=ws2.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Next i
End If
x = 0: y = 0
If Not .Range("M" & user.Row) = 0 Then
Set ws1 = Sheets("NCRTC")
Set ws2 = Sheets("NCRTC Smpl")
For i = 1 To .Range("M" & user.Row)
y = x
On Error Resume Next
x = x + WorksheetFunction.Match(user, ws1.Range("L" & x + 1 & ":L" & ws1.Cells(Rows.Count, "L").End(xlUp).Row), 0)
On Error GoTo 0
If y = x Then Exit For
ws1.Rows(x).Copy Destination:=ws2.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Next i
End If
x = 0: y = 0
Next user
End With
End Sub
Last edited: