KIM Chanthan
Member
Hello,
I have 2 sheets. One is all data and another one is Daily Target.
Everyday, i need to generate 5 sample record per office to store in Daily Target.
After that, i need to mark those record as Picked in sheet All Data. Next day, i need to generate another 5 records which its status is not Picked.
I tried with below code, but seems it spend much time until not response.
Can you help to recommend what should i do to get it done faster and correctly?
>>> use code - tags <<<
Please, You should reread instructions - how to use code - tags.
Code:
I have 2 sheets. One is all data and another one is Daily Target.
Everyday, i need to generate 5 sample record per office to store in Daily Target.
After that, i need to mark those record as Picked in sheet All Data. Next day, i need to generate another 5 records which its status is not Picked.
I tried with below code, but seems it spend much time until not response.
Can you help to recommend what should i do to get it done faster and correctly?
>>> use code - tags <<<
Please, You should reread instructions - how to use code - tags.
Code:
Code:
Sub generate()
Set ws_all = Worksheets("All Data")
Set ws_Tag = Worksheets("Daily Target")
Range("B4:D100000").ClearContents
For i = 2 To 30580
For j = 4 To 748
n = Application.WorksheetFunction.CountA(Range("D:D")) + 3
If ws_all.Range("A" & i).Value = ws_Tag.Range("A" & j).Value And ws_all.Range("V" & i).Value <> "Picked" Then
ws_Tag.Range("B" & n & ":D" & n).Value = ws_all.Range("C" & i & ":E" & i).Value
Exit sub
End If
Next j
Next i
End Sub
Attachments
Last edited by a moderator: