Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 44
Default Array-problem

Hi

I'd like to read the values from a range into an array. Does anybody know,
how to make my example work?

Tom


Sub Test()
Dim aValues As Variant
Dim i As Integer

With ActiveSheet.Range("A1:A10")
aValues = .Value
End With

For i = 1 To UBound(aValues)
Debug.Print aValues(i)
Next i
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Array-problem

Hi Tom

The created array will be a 2-dimensional one,
so in your situation with only one column use

For i = 1 To UBound(aValues,1)
Debug.Print aValues(i,1)
Next i

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Tom" skrev i en meddelelse
...
Hi

I'd like to read the values from a range into an array. Does anybody know,
how to make my example work?

Tom


Sub Test()
Dim aValues As Variant
Dim i As Integer

With ActiveSheet.Range("A1:A10")
aValues = .Value
End With

For i = 1 To UBound(aValues)
Debug.Print aValues(i)
Next i
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Array-problem

In addition to Leo, if you wish to keep it as a 1-Dim array, you could use
something like this:

Sub Test()
Dim aValues As Variant
Dim i As Integer

aValues = WorksheetFunction.Transpose(Range("A1:A10").Value)

For i = LBound(aValues) To UBound(aValues)
Debug.Print aValues(i)
Next i
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Tom" wrote in message
...
Hi

I'd like to read the values from a range into an array. Does anybody know,
how to make my example work?

Tom


Sub Test()
Dim aValues As Variant
Dim i As Integer

With ActiveSheet.Range("A1:A10")
aValues = .Value
End With

For i = 1 To UBound(aValues)
Debug.Print aValues(i)
Next i
End Sub




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
3D Array Problem sgl Excel Worksheet Functions 2 July 6th 09 06:46 AM
Array problem, I think.. Steve Excel Worksheet Functions 3 June 11th 08 12:38 AM
Array problem - TIA S Davis Excel Worksheet Functions 9 November 7th 06 02:22 AM
Array Problem Scott Excel Discussion (Misc queries) 4 May 9th 06 05:22 PM
Array Problem, Help Please. Bubu Excel Programming 9 November 18th 03 04:29 PM


All times are GMT +1. The time now is 11:01 PM.

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"