HELP ON ARRAY CUSTOM FUNCTION NEEDED

CSTUBBS

New Member
Joined
Feb 13, 2007
Messages
45
I need to list out all unique values in cells A2,A3,andA4. Currently using a sort concatenate function found in --VBA and Macros for Excel that can probably be modified. Below is the SortConcat code, and a condensed version of the sheet.I need to modify the code so that it:
1)skips zeros
2)skips dates
3) will handle a single row,horizontal array 164 columns wide
4) sort in ascending order with numbers contained in parenthesis at the end
This spreadsheet will get approximately 30 rows of data a week. The formula will eventually be put in A1 and all data is copied/paste special values only to the next row, so all formulas are only in row 1.(TMI)
Code:
Option Explicit

Function SortConcat(Rng As Range) As Variant
    'Rng —The range of data to be sorted and concatenated.
    Dim MySum As String, arr1() As String
    Dim j As Integer, i As Integer
    Dim cl As Range
    Dim concat As Variant
    On Error GoTo FuncFail:
    'initialize output
    SortConcat = 0#
    'avoid user issues
    If Rng.Count = 0 Then Exit Function
    'get range into variant variable holding array
    ReDim arr1(1 To Rng.Count)
    'fill array
    i = 1
    For Each cl In Rng
        arr1(i) = cl.Value
        i = i + 1
    Next
    'sort array elements
    Call BubbleSort(arr1)
    'create string from array elements
    For j = UBound(arr1) To 1 Step -1
        If Not IsEmpty(arr1(j)) Then
            MySum = arr1(j) & "," & MySum
        End If
    Next j
    'assign value to function
    SortConcat = Left(MySum, Len(MySum) - 1)
    'exit point
concat_exit:
    Exit Function
    'display error in cell
FuncFail:
    SortConcat = Err.Number & "-" & Err.Description
    Resume concat_exit
End Function

Sub BubbleSort(List() As String)
' Sorts the List array in ascending order
    Dim First As Integer, Last As Integer
    Dim i As Integer, j As Integer
    Dim Temp
    
    First = LBound(List)
    Last = UBound(List)
    For i = First To Last - 1
        For j = i + 1 To Last
            If UCase(List(i)) > UCase(List(j)) Then
                Temp = List(j)
                List(j) = List(i)
                List(i) = Temp
            End If
        Next j
    Next i
End Sub

Sheet
test for demension macro.xls
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1currentoutputneededoutput111DATE112DATE113DATE114DATE121DATE122DATE123DATE124DATE131DATE132DATE133DATE134DATE
2(6/6),(6/8),0,0,0,12:00:00AM,12:00:00AM,12:00:00AM,4/16/2007,4/17/2007,4/19/2007,4/19/2007,4/19/2007,4/19/2007,4/20/2007,4/20/2007,4/20/2007,6,6,6,6,6,6,86,8,(6/6),(6/8)84/1764/1964/2001/064/16(6/8)4/19(6/6)4/2001/064/2064/1964/1901/0
310,10,10,10,12,12,12,12,12,12,12,12,4/19/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/2007,4/20/200710,12104/20104/20104/20104/20124/20124/20124/20124/19124/20124/20124/20124/20
44,4,4,4,4,4,4,4,4,4,4,4,4/10/2007,4/17/2007,4/18/2007,4/18/2007,4/18/2007,4/18/2007,4/19/2007,4/19/2007,4/19/2007,4/20/2007,4/20/2007,4/9/2007444/2044/1844/944/1944/1944/1944/1844/1744/1844/1844/2044/10
5
6
7
Sheet1
 
Thanks again,Andrew. I'm in overload right now so it will be a few days before I get back to this project. Will probably plug it in this weekend and check it out.
Again, thanks sooooo much
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top