LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default How to create a function?

I use below code to store the unique record in a array - sUCells()
and count the number of element of the array - iUVals

Since I use this code more than one time in my template.
To easy reading and maintain.
Can I set a function to return two objtct "sUCells() & iUVals" ?
Any suggest? Thanks.

Dim myrange As Range
Dim cell As Range
Dim j As Integer
Dim iNumCells As Integer
Dim iUVals As Integer
Dim sUCells() As String
Dim lastrow As Integer
lastrow = Worksheets("Data").Cells(Rows.Count, "A").End(xlUp).Row

Set myrange = Range("A2:A" & lastrow)
iNumCells = myrange.Count
ReDim sUCells(iNumCells) As String

iUVals = 0
For Each cell In myrange
If cell.Text "" Then
For j = 1 To iUVals
If sUCells(j) = UCase(cell.Text) Then
Exit For
End If
Next j
If j iUVals Then
iUVals = iUVals + 1
sUCells(iUVals) = UCase(cell.Text)
End If
End If
Next cell
Set myrange = Nothing
Set cell = Nothing
If iUVals = 0 Then Exit Sub

For i = 1 To iUVals
...
Next i
 
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 to create function to look up the value TT Excel Discussion (Misc queries) 0 April 27th 09 07:54 AM
How to create an IF function Cindygirl Excel Worksheet Functions 1 March 25th 09 09:56 PM
How to create a function galsaba Excel Worksheet Functions 2 January 29th 07 11:29 AM
How do I create a function into function list? Hossein Farhani Excel Programming 2 April 23rd 05 06:19 PM
What function would I create? pookie1394 Excel Worksheet Functions 0 March 11th 05 03:07 PM


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