Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Deleting blank values from an array

Hi... newbie here. I have a 2D array that has blank values that I would like
to remove. I searched and found this code:

'Where Arr is array containing blanks and Arr2 is dynamic array
ii = 0
For i = LBound(Arr) To UBound(Arr)
If Arr(i) < "" Then
ReDim Preserve Arr2(ii)
Arr2(ii) = Arr(i)
ii = ii + 1
End If
Next

However, I am getting an error 9: subscript out-of-range for the "If Arr(i)
< "" Then" line and I can't figure out why. The only thing I can think of is
that this code is for a 1D array? Any comments? If so, how do I change the
code to remove blanks from a 2D array. Thanks!

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Deleting blank values from an array

Matt,
How about putting this line in your code temporarily to see what is
going on:
MsgBox "i: " & i

I'd put it right after the "For i = blah blah....

Alan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Deleting blank values from an array

Hi Alan,

Thanks for the help, that tip should definitely help me debug in the future.
I ended up changing the code so that a 1D array will work and now I am
getting acceptable results. My philosophy is to make the program as simple as
possible at first and then add more difficult-to-code extras later on once I
at least have a working version.

Matt

"alan_stew" wrote:

Matt,
How about putting this line in your code temporarily to see what is
going on:
MsgBox "i: " & i

I'd put it right after the "For i = blah blah....

Alan


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
Not showing blank and non blank items in filter mode for values Bhaskar Polisetty Excel Worksheet Functions 0 June 20th 06 02:04 PM
Deleting all but one blank row RealGomer Excel Discussion (Misc queries) 2 February 16th 06 06:55 PM
deleting values in a worksheet without deleting the formulas patti Excel Worksheet Functions 1 October 28th 05 09:49 PM
Deleting blank values from an array Rich J[_2_] Excel Programming 6 June 1st 05 11:28 PM
Deleting element in Array ExcelMonkey[_190_] Excel Programming 3 March 28th 05 02:47 AM


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