Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combining related unique (distinct) values from two columns into an array

Hi,

I need to do the following with VBA and I've run into a mental
stumbling block.

I need to combine related unique values from two columns into an array.

For example

Column A








Column B
Text
Text
Text
HTML
HTML
text

So I need the unique e-mail address from Column A along with it's
related value in column B and store that into an array so I can split
it up.

I'm pretty new to Excel programming so any guidance is greatly
appreciated.

I have the following code (which I got from this group) which will get
the unique e-mail addresses but I don't know how to pair them up with
their related values from column B

Function DistinctArray(oInputArray, _
Optional MatchCase As Boolean = True, _
Optional OmitBlanks As Boolean = True)

Dim oOutputArray As Variant
Dim oElement As Variant

Set oDictionary = CreateObject("Scripting.Dictionary")

oDictionary.CompareMode = Abs(Not MatchCase)

For Each oElement In oInputArray
oDictionary.Item(CStr(oElement)) = oElement
Next

If OmitBlanks Then
If oDictionary.Exists("") Then oDictionary.Remove ("")
End If

oOutputArray = oDictionary.Items

DistinctArray = oOutputArray

End Function

================================================== ====================

Private Sub CommandButton3_Click()

Dim arr1(), arr2()

arr1 = Range("A2:A65536").SpecialCells(xlCellTypeVisible)
arr2 = DistinctArray(arr1)

For intPosition = LBound(arr2) To UBound(arr2)
MsgBox (arr2(intPosition))
Next

End Sub

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
Auto correct/update values in two related columns Tinman4 New Users to Excel 0 January 3rd 12 05:45 PM
Unique values in an array. Jerry Excel Discussion (Misc queries) 2 October 15th 09 06:44 PM
Array formula for unique values Dan Hatola Excel Worksheet Functions 1 January 20th 07 03:06 AM
Determining number of values in an array (2 related questions) KR Excel Programming 3 March 4th 05 09:33 PM
Frequncy of unique values in array Fábio Coatis Excel Programming 3 July 22nd 03 05:53 AM


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