Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Populating 2-D array w/ Application.[Function] results

I have a sheet that has multiple occurrences of values in Column A. I
already have made an array that has the UNIQUE values: Array1.

I now need to make an Array2 that has the items from Array1 as its 1st
column, and the number of times each item appears in Column A in its second
column. You can probably see what I'm trying to do by looking at this:

For i = 0 To UBound(Array1)
ReDim Preserve Array2(0 To i, 0 To y)
Array2(i, y) = (Array1(i),
Application.CountIf(Sheets("SheetName").Range("A1: A39"), Array1(i))))
i = i + 1
Next i

Or, I could even just ADD the Count as a new "column" or "dimension" to the
existing Array1, either way is fine with me. I just can't seem to figure out
the right syntax for populating the 2nd part of the array, or making a new
array that has the elements from the 1st array and the count of times that
element appears in Column A.

I feel embarrassed at having to ask such a simple question; the truth is all
the stuff about populating arrays that I could find was either for a 1-D
(which I knew already), or things MORE complex than what I'm trying to do; I
couldn't find the sweet spot.

I appreciate any help, and thanks for reading.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Populating 2-D array w/ Application.[Function] results

Add some code to insert a column after the column of unique values, and add
a simple SUMIF formula. Then just load the array wholesale from those 2
columns.


HTH

Bob

"CompleteNewb" wrote in message ...

I have a sheet that has multiple occurrences of values in Column A. I
already have made an array that has the UNIQUE values: Array1.

I now need to make an Array2 that has the items from Array1 as its 1st
column, and the number of times each item appears in Column A in its second
column. You can probably see what I'm trying to do by looking at this:

For i = 0 To UBound(Array1)
ReDim Preserve Array2(0 To i, 0 To y)
Array2(i, y) = (Array1(i),
Application.CountIf(Sheets("SheetName").Range("A1: A39"), Array1(i))))
i = i + 1
Next i

Or, I could even just ADD the Count as a new "column" or "dimension" to the
existing Array1, either way is fine with me. I just can't seem to figure out
the right syntax for populating the 2nd part of the array, or making a new
array that has the elements from the 1st array and the count of times that
element appears in Column A.

I feel embarrassed at having to ask such a simple question; the truth is all
the stuff about populating arrays that I could find was either for a 1-D
(which I knew already), or things MORE complex than what I'm trying to do; I
couldn't find the sweet spot.

I appreciate any help, and thanks for reading.

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
Alternative to Application.Caller in array functions to avoid wrong results? Joe User[_2_] Excel Programming 10 November 4th 09 06:28 PM
Passing result of multiple split function results to 1 Array ExcelMonkey Excel Programming 5 January 19th 08 07:55 AM
PLEAS HELP! Newby Needs help Populating Cell w/ Application.usern zulfer7 Excel Discussion (Misc queries) 3 June 22nd 06 09:53 PM
Wanting to write results to array instead of sheet, results overwriting.... [email protected] Excel Programming 2 October 31st 05 01:47 PM
populating one list/combobox based on the results of another Tim[_39_] Excel Programming 1 December 6th 04 04:53 PM


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