VB Marco Reverse Variant and paste into other sheet

C

Chuo Chung Seng

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

Regards
Chuo
 
J

Jim Cone

An array picked up from a range has the same number of rows and columns as the range.
So your Avalue() array is actually an array of 498 rows and 1 column.
You have to specify both dimensions to access it...

Avalue(i, 1) = StrReverse(Avalue(i, 1))
'---
Jim Cone
Portland, Oregon USA .
http://www.mediafire.com/PrimitiveSoftware .
(XL Companion add-in: compares, matches, counts, lists, finds, deletes...)



"Chuo Chung Seng" <[email protected]>
wrote in message
news:c2eccb90-7f7a-4c3c-98cb-b46506fc6985@ea4g2000vbb.googlegroups.com...
 
C

Chuo Chung Seng

Yes, it run without error bro.
Thanks a lot Jim. I'm newbie on vb.

Regards
Chuo
 

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