I am working on a excel vba based project where I need to extract random set of data from a given dump. I have prepared the data and it is working fine , Only the problem is sometimes it is selecting the same data twice. I have used the rnd() function for picking the data in random manner but still sometimes it giving same output. Below is the code. Please help me out.
For i = 1 To Worksheets("Output").range("D7").Value - 1
lowest = 1
highest = Worksheets("Output").range("T5")
Randomize
generateno = Int((highest - lowest + 1) * Rnd() + lowest)
Gen = generateno
Sheets("Workings").Select
range("B1").Select
ActiveCell.Offset(Gen, 0).Select
range(Selection, ActiveCell.Offset(0, 3)).Select
Selection.Copy
Sheets("Output").Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next i
Aucun commentaire:
Enregistrer un commentaire