Named range in an array

F

Frigster

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.
 
T

Tom Ogilvy

dim v as Variant
v = Range("xyz").Value

for i = 1 to 5
msgbox v(i,1)
Next


If you want a 1D array

v = application.Transpose("xyz")

for i = 1 to 5
msgbox v(i)
Next
 
A

Alan Beban

Tom said:
dim v as Variant
v = Range("xyz").Value

for i = 1 to 5
msgbox v(i,1)
Next


If you want a 1D array

v = application.Transpose("xyz")'<---A typo:v = application.Transpose(Range("xyz"))

for i = 1 to 5
msgbox v(i)
Next
Alan Beban
 
C

ccroche

Sorry, I think there is again a typo ...

If you want a 1D array
v = application.WorkSheetFunction.Transpose(Range("xyz"))

Christian CROCHE
 

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