PC Review


Reply
Thread Tools Rate Thread

Combining related unique (distinct) values from two columns into an array

 
 
cmwilliams@gmail.com
Guest
Posts: n/a
 
      2nd Nov 2006
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

(E-Mail Removed)
(E-Mail Removed)
(E-Mail Removed)
(E-Mail Removed)
(E-Mail Removed)
(E-Mail Removed)

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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
COMBINING UNIQUE VALUES FROM 4 COLUMNS INTO 1 watembo Microsoft Access 5 18th Aug 2010 10:30 PM
COMBINING UNIQUE VALUES FROM 4 COLUMNS INTO 1 watembo Microsoft Access 0 14th Aug 2010 09:47 PM
Storing distinct values in an array shimeel Microsoft Excel Misc 2 1st Nov 2004 07:08 PM
Storing distinct values in an array shimeel Microsoft Excel Misc 1 1st Nov 2004 06:59 PM
Re: Distinct/Unique Values Ken Wright Microsoft Excel Misc 0 15th Aug 2003 08:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:39 PM.