Named range into an array
Hi,
I have five cells on a row (A1:A5). This range is named "xyz". How can I transform this range in an array with VB code? Thank you. Paolo. |
Named range into an array
Try:
Sub gsnu() Dim r As Range Dim v(10) i = 1 For Each r In Range("xyz") v(i) = r.Value i = i + 1 If i = 6 Then Exit For Next End Sub as coded it picks up the first 5 values in "xyz" and does not examine Range("xyz").Count to get the full range. Note that Range("xyz") is the equivalent of Range("A1:A5"). A Name is just a string. -- Gary''s Student "Frigster" wrote: Hi, I have five cells on a row (A1:A5). This range is named "xyz". How can I transform this range in an array with VB code? Thank you. Paolo. |
Named range into an array
?????
Dim arr(1 to 5) arr = Range("xyz") Alan Beban Gary''s Student wrote: Try: Sub gsnu() Dim r As Range Dim v(10) i = 1 For Each r In Range("xyz") v(i) = r.Value i = i + 1 If i = 6 Then Exit For Next End Sub as coded it picks up the first 5 values in "xyz" and does not examine Range("xyz").Count to get the full range. Note that Range("xyz") is the equivalent of Range("A1:A5"). A Name is just a string. |
All times are GMT +1. The time now is 01:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com