Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Load selection into an Array - VBA

How do I take a selection of cells on the sheet and load them into an
Array in VBA?

-Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Load selection into an Array - VBA

Dim arr

arr = Range(Cells(1), Cells(10, 10))


RBS


"brittonsm" wrote in message
...
How do I take a selection of cells on the sheet and load them into an
Array in VBA?

-Steve


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Load selection into an Array - VBA

One way:

Dim vArr As Variant

vArr = Range("A1:J10").Value

which loads the values in the range into a (1 To 10, 1 to 10) variant
array.



In article
,
brittonsm wrote:

How do I take a selection of cells on the sheet and load them into an
Array in VBA?

-Steve

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Load selection into an Array - VBA

brittonsm wrote:
How do I take a selection of cells on the sheet and load them into an
Array in VBA?

-Steve

You've received two valid answers for a Variant() array or an array
contained within a Variant variable. If that is not your situation, post
back.

Alan Beban
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Load selection into an Array - VBA

In the worst case, if your selection is a pile on non-contiguous cells, then:

Sub sel_to_array()
Dim ar() As Variant
ReDim ar(1 To Selection.Count) As Variant
i = 1
For Each r In Selection
ar(i) = r.Value
i = i + 1
Next
End Sub
--
Gary''s Student - gsnu2007j


"brittonsm" wrote:

How do I take a selection of cells on the sheet and load them into an
Array in VBA?

-Steve

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
listbox selection to load to new form [email protected] Excel Programming 4 November 1st 07 07:12 PM
How do you dynamically load an array? havocdragon Excel Programming 2 October 24th 06 07:26 PM
Load UserForm1 on sheet tab selection Wayne_Perth_WA Excel Programming 1 August 10th 05 01:39 AM
Load an array with Sheet names S G Booth Excel Programming 6 March 2nd 05 08:48 PM


All times are GMT +1. The time now is 06:20 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"