Hello,
may I ask you for your help with following code? I have been struggling for some hours and now I seem to be lost completely.
What I am trying to do: I have a table with some document details starting the area from A6 to K6 and with variable count of rows. I need to choose randomly 20% of them and put an "X" in the column L. My approach is following:
I always get stuck on the last line:Code:'In the column L, put a formula which will read the randomly chosen document numbers (from column P) and put an "X" when found With Sheets("Sheet3") lngLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row .Range("L6:L" & lngLastRow).FormulaR1C1 = "=IFERROR(IF(VLOOKUP(RC[-7],C[4],1,0)=RC[-7],""X"",""""),"""")" 'Copy the document numbers from the column E into the available column N .Columns("E:E").Select Selection.Copy Destination:=Columns("N:N") 'Use RAND formula and paste it as a value .Range("O6:O" & lngLastRow).FormulaR1C1 = "=RAND()" .Columns("O:O").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False End With 'Use Index formula to determine the random values With Sheets("Sheet3") lngLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row .Range("P6").Select .Range("P6:P" & lngLastRow).FormulaR1C1 = "=INDEX(R6C14:R & lngLastRow,RANK(RC[-1],R6C15:R & lngLastRow))" End With
I really don't know what is wrong. Can you please help me?Code:.Range("P6:P" & lngLastRow).FormulaR1C1 = "=INDEX(R6C14:R & lngLastRow,RANK(RC[-1],R6C15:R & lngLastRow))"
Thank you very much, SaburaZera



Reply With Quote
Bookmarks