Error 1004 en el método "Range" de _objeto
Publicado por anthony (2 intervenciones) el 28/05/2019 23:15:14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Private Sub CommandButton2_Click()
Dim i As Integer
Dim Valor1 As Variant, Valor2 As Variant, Valor3 As Variant, lookupRange As Range
Sheets("BD").Select
Set lookupRange = Range("A2:D15001")
Application.ScreenUpdating = False
Set unicos = New Collection
x = 1 'núm inicial del rango de valores
y = 15000 'núm final del rango de valores
Sheets("Panel").Select
z = Range("07").Value 'numero de elementos no repetidos que queremos (AQUI ME SALE EL ERROR)
Randomize
Sheets("MAS").Select
Range("A2").Select
Do Until unicos.Count = z
ale = Int((y - x + 1) * Rnd + x)
On Error Resume Next
unicos.Add ale, CStr(ale)
On Error GoTo 0
Loop
'escribir los datos unicos en la hoja de calculo
For i = 1 To unicos.Count
Sheets(MAS).Range("A2").Offset(i - 1, 0).Value = unicos(i)
Valor1 = Application.VLookup(Sheets("MAS").Range("A2").Offset(i - 1, 0).Value, lookupRange, 2, False)
Valor2 = Application.VLookup(Sheets("MAS").Range("A2").Offset(i - 1, 0).Value, lookupRange, 3, False)
Valor3 = Application.VLookup(Sheets("MAS").Range("A2").Offset(i - 1, 0).Value, lookupRange, 4, False)
Sheets("MAS").Range("A2").Offset(i - 1, 1).Value = Valor1
Sheets("MAS").Range("A2").Offset(i - 1, 2).Value = Valor1
Sheets("MAS").Range("A2").Offset(i - 1, 3).Value = Valor1
Next i
End Sub
Por fa quisiera saber como solucionarlo,ayudemen porfa lo necesito :(
Valora esta pregunta


0