LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ReDim, Preserve and Multidimensional arrays

Running Windows XP and Office XP.
I am trying to store data returned from a search into a dynamic
multidimensional array with the following code,

If currentCell.Value Like searchText Then
i = i + 1
ReDim Preserve searchResults(i, 4)
searchResults(i, 1) = ActiveSheet.Name
searchResults(i, 2) = currentCell.Value
searchResults(i, 3) = descriptionCell.Value
searchResults(i, 4) = priceCell.Value
End If

having declared the array at the top of the procedure with

Dim searchResults() As Variant

Problem is that the code always halts with a "subscript out of range" error
message when i = 2. If I remove the Preserve then the code runs fine except
I only have the last line of search data.

Any ideas anybody?

 
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
VBA syntax help: ReDim Preserve an array Dave Excel Discussion (Misc queries) 4 September 8th 07 07:37 PM
Declare Multidimensional Arrays Alan Beban[_3_] Excel Programming 3 August 21st 03 02:40 AM
Declare Multidimensional Arrays Alan Beban[_3_] Excel Programming 0 August 20th 03 07:03 PM
Multidimensional Arrays - VBA Brent McIntyre Excel Programming 3 August 11th 03 09:01 AM
Multidimensional Arrays - VBA Brent McIntyre Excel Programming 14 August 8th 03 10:49 PM


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

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

About Us

"It's about Microsoft Excel"