Transferring a range to a variant array

William_Mejia

New member
Joined
Jul 3, 2019
Messages
2
Reaction score
0
Points
0
Excel Version(s)
2016
Can someone explain me why the error 13 is occurring. It is something with the line: x(r, c) = x(r, c) * 2

Code:
Sub RangeToVariant2()

    Dim UserRange As Range
    Dim x As Variant
    Dim r As Long, c As Integer

    Set UserRange = Range("A1:L600")
    
    x = Range("A1:L50")

    For r = 1 To UBound(x, 1)
        For c = 1 To UBound(x, 2)
        'Multiplicar por 2
        x(r, c) = x(r, c) * 2
        Next c
    Next r

    Range("A1:L50") = x

End Sub

I appreciate your help!
 
Last edited by a moderator:
Hi and welcome
please wrap your code with code tags in the future. Thanks
 
I would suspect that one of the cells in A1:L50 either contains text, or contains an error.
 
That was it. I had a cell with text. Thanks a lot!
 
Back
Top