Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 200
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Picking out column in named range Basil Excel Worksheet Functions 2 September 2nd 06 10:45 AM
Named range causing really weird problems - HELP Abbas Excel Discussion (Misc queries) 0 July 26th 06 05:55 PM
Array Formula Not Working with Range with Formulas [email protected] Excel Discussion (Misc queries) 4 February 1st 06 02:01 PM
Pivot Tables - Named Range dipsy Excel Worksheet Functions 5 August 23rd 05 04:50 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM


All times are GMT +1. The time now is 07:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"