Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
newengland
 
Posts: n/a
Default how to convert an array


Hi

I have an array of values as follows

3 25
1 10
4 12
6 7

the first column represents the number of instances of the row. I
would like to convert this as follows:

25
25
25
10
12
12
12
12
7
etc.

how can I do this formulaically? or formulaically with a UDF?

thanks


--
newengland
------------------------------------------------------------------------
newengland's Profile: http://www.excelforum.com/member.php...fo&userid=5946
View this thread: http://www.excelforum.com/showthread...hreadid=490855

  #2   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default how to convert an array

Hello,

A suggestion for a UDF:
Option Explicit

Function one_dim_array(rI As Range) As Variant
'Converts an argument array of frequencies and values into
'a one-dimensional array.
'Example:
'3 25
'1 10
'4 12
'6 7
'will become 25 25 25 10 12 12 12 12 7 7 7 7 7 7.
'Remember to select sufficient count of cells for result
'and to enter function as array-formula (CTRL + SHIFT + ENTER).
Dim vR As Variant
Dim r As Range
Dim b As Boolean
Dim lF As Long, i As Long, j As Long

With Application.Caller

ReDim vR(1 To .Rows.Count, _
1 To .Columns.Count)
i = 1
j = 1
b = True
For Each r In rI
If b Then
lF = r.Value
Else
Do While lF 0
vR(i, j) = r.Value
j = j + 1
If j .Columns.Count Then
j = 1
i = i + 1
End If
lF = lF - 1
Loop
End If
b = Not b
Next r

End With

one_dim_array = vR

End Function

HTH,
Bernd

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
How do I convert a row of cells into a two-dimensional array? Glenn@stress Excel Worksheet Functions 7 October 10th 05 07:28 PM
CONVERT Function Disappered in Excel Gord Dibben Excel Discussion (Misc queries) 3 April 13th 05 07:59 PM
Convert Numeric into Text Monty Excel Worksheet Functions 0 December 18th 04 09:25 PM
Formula to list unique values JaneC Excel Worksheet Functions 4 December 10th 04 12:25 AM
VBA Import of text file & Array parsing of that data Dennis Excel Discussion (Misc queries) 4 November 28th 04 10:20 PM


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