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: 19
Default Function to resize an array

Hi all...
I was trying to write a function that would help me resize
an array in such a way that when I apply the function to
it, it will eliminate the *empty spaces* of the array.

The array I'm trying to modifie is like the one that would
return a formula like =IF(A1:J1=1,A2:J2,"") for each cell
different from 1 on row 1 I would get a empty space in my
array so if I have

A B C D E F G H I J
R1 1 2 1 1 3 2 1 2 2 1
R2 3 4 2 5 7 2 6 4 5 8

my formula would result in {3, ,2,5, , ,6, , ,8}
and after applying my new function which I called
CleanArr, the result would be {3,2,5,6,8}

Here's were I'm at now:
'========================================
Function CleanArr(OrArr As Variant) As Variant
Dim i, j, k As Integer
Dim FixArr(), CPArr() As Variant

CPArr = OrArr
i = 0
For j = 1 To UBound(CPArr())
If CPArr(j) < Empty Then i = i + 1
Next j
ReDim FixArr(i - 1)
j = 1
For k = 0 To UBound(FixArr())
If CPArr(j) < Empty Then
FixArr(k) = CPArr(j)
Else
k = k - 1
End If
j = j + 1
Next k
CleanArr = FixArr
End Function
'========================================

As it is above, it works, if I use:
=CleanArr(IF(A1:J1=1,A2:J2,"")CTR+SHF+ENT, it will return
{3,2,5,6,8}

But... and here's were I'm stuck, if I use it in a column
orientation i.e. =CleanArr(IF(A1:A10=1,B1:B10,""))

It returns #VALUE!

I am LOST how can I make it work in both orientations,
it's intended for single dimension arrays but I want it to
work either in a row or a column...

Any help is greatly appreciated...

TIA
Juan




 
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
OR function in array-entered IF function veggies27 Excel Worksheet Functions 8 March 11th 08 06:32 PM
I could NOT resize the axis title but excel allows me to resize gr Iwan Setiyono Ko Charts and Charting in Excel 4 June 6th 06 04:46 AM
I could NOT resize the axis title but excel allows me to resize gr Iwan Setiyono Ko Charts and Charting in Excel 0 March 15th 06 10:34 AM
How to resize a comment box, by embedding code into a function? JJ Excel Worksheet Functions 13 November 16th 04 08:44 PM
UDF Array function Dave Peterson[_3_] Excel Programming 0 July 10th 03 04:30 AM


All times are GMT +1. The time now is 08:55 PM.

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"