VB Marco Reverse Variant and paste into other sheet

C

Chuo Chung Seng

Hi All,

I have some error occur during reversing an Variant.
The Avalue(i) = StrReverse(Avalue(i)) having error mention that
"Subscript out of range"
Anyone can advise an solution to me pls.....

Dim Avalue() As Variant

Sheets("Sheet1").Select
Avalue = Range("B3:B500").Value


For i = LBound(Avalue) To UBound(Avalue)
Avalue(i) = StrReverse(Avalue(i))
Next i

Sheets("Sheet2").Select
Range("B3:B500") = Avalue


End Sub
 
Joined
Jul 19, 2011
Messages
20
Reaction score
0
By default, the array is two dimensional when you set a variant to a range (since ranges can be 2D)
For i = LBound(Avalue, 1) To UBound(Avalue, 1)
Avalue(i, 1) = StrReverse(Avalue(i, 1))
Next i

If your values were in a row, you would iterate on the second dimension (the columns).

Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top