Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default array filling: cell addresses

Hello everybody,

I'm trying to fill an array with the cell addresses of several separately
selected cells.

This is what I have so far:

........
Option Explicit

Sub test()
Dim cell As Range
Dim CellAdresses() As Variant
For Each cell In Selection
CellAdresses(cell) = cell.Address
Next cell
End Sub
......

Doing this gets me error number 9 Subscript out of range.

It's propably a simple thing I'm overlooking. Please help.

Peter.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default array filling: cell addresses

Option Explicit

Sub test()
Dim cell As Range
Dim CellAdresses() As Variant
Dim i as Long
Redim cellAdresses(1 to selection.Count)
i = 0
For Each cell In Selection
i = i + 1
CellAdresses(i) = cell.Address
Next cell
End Sub


--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
Hello everybody,

I'm trying to fill an array with the cell addresses of several separately
selected cells.

This is what I have so far:

.......
Option Explicit

Sub test()
Dim cell As Range
Dim CellAdresses() As Variant
For Each cell In Selection
CellAdresses(cell) = cell.Address
Next cell
End Sub
.....

Doing this gets me error number 9 Subscript out of range.

It's propably a simple thing I'm overlooking. Please help.

Peter.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default array filling: cell addresses

If the selections are truly individual cells, would this idea help?

Sub Demo()
Dim CellAdresses
Range("A1,B3,C5,D4,E3,F2,G1").Select

CellAdresses = Split(Selection.Address(False, False), ",")
End Sub

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


"Peter" wrote in message
...
Hello everybody,

I'm trying to fill an array with the cell addresses of several separately
selected cells.

This is what I have so far:

.......
Option Explicit

Sub test()
Dim cell As Range
Dim CellAdresses() As Variant
For Each cell In Selection
CellAdresses(cell) = cell.Address
Next cell
End Sub

Doing this gets me error number 9 Subscript out of range.

It's propably a simple thing I'm overlooking. Please help.

Peter.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default array filling: cell addresses

Thanks Tom, that's what I needed.

Peter


"Tom Ogilvy" schreef in bericht
...
Option Explicit

Sub test()
Dim cell As Range
Dim CellAdresses() As Variant
Dim i as Long
Redim cellAdresses(1 to selection.Count)
i = 0
For Each cell In Selection
i = i + 1
CellAdresses(i) = cell.Address
Next cell
End Sub


--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
Hello everybody,

I'm trying to fill an array with the cell addresses of several

separately
selected cells.

This is what I have so far:

.......
Option Explicit

Sub test()
Dim cell As Range
Dim CellAdresses() As Variant
For Each cell In Selection
CellAdresses(cell) = cell.Address
Next cell
End Sub
.....

Doing this gets me error number 9 Subscript out of range.

It's propably a simple thing I'm overlooking. Please help.

Peter.






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
Drag-filling a formula Array Jacob C. Excel Discussion (Misc queries) 5 April 9th 09 09:20 PM
help with filling in an array formula Caitlin Excel Discussion (Misc queries) 5 November 7th 06 08:12 PM
Filling a List Box in Excel from an Array Martin Excel Discussion (Misc queries) 4 October 18th 05 11:50 AM
Filling excel entire row/column instead of single cell from an array shitij Excel Worksheet Functions 3 July 13th 05 07:44 AM
Filling an array with data Dongle Excel Worksheet Functions 2 May 18th 05 06:06 PM


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