Aretradeser
Board Regular
- Joined
- Jan 16, 2013
- Messages
- 176
- Office Version
- 2013
- Platform
- Windows
Regarding these two macros, I need:
1. That in the extraction of the 5 records, do not include the title of the column.
2. Join both codes.
Thank you very much
CÓDIGO 1
CÓDIGO 2
1. That in the extraction of the 5 records, do not include the title of the column.
2. Join both codes.
Thank you very much
CÓDIGO 1
Rich (BB code):
Sub RegistrosAleatorios1()
Dim arr As Variant
Dim i As Long, x As Long, y As Long, n As Long
'
n = Sheets("Hoja3").Range("C" & Rows.Count).End(3).Row
Randomize
arr = Evaluate("=row(1:" & n & ")")
'
For i = 1 To n
x = Int(UBound(arr) * Rnd + 1)
y = arr(x, 1)
arr(x, 1) = arr(i, 1)
arr(i, 1) = y
Next
'
For i = 1 To 5
Sheets("Hoja1").Range("C11").Offset(0, i - 1).Value = Sheets("Hoja3").Range("C" & arr(i, 1))
Next
End Sub
Rich (BB code):
Sub RegistrosAleatorios2()
Dim arr As Variant
Dim i As Long, x As Long, y As Long, n As Long
'
n = Sheets("Hoja5").Range("C" & Rows.Count).End(3).Row
Randomize
arr = Evaluate("=row(1:" & n & ")")
'
For i = 1 To n
x = Int(UBound(arr) * Rnd + 1)
y = arr(x, 1)
arr(x, 1) = arr(i, 1)
arr(i, 1) = y
Next
'
For i = 1 To 5
Sheets("Hoja1").Range("C16").Offset(0, i - 1).Value = Sheets("Hoja5").Range("C" & arr(i, 1))
Next
End Sub