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: 3
Default Change when function is called

Hi,
I have the following function that is called everytime a worksheet is
changed, I would like to only allow the function to run on certain
worksheets because I have code on other sheets and having this
function called makes it really slow, so is there a way to specify
which sheets can call the function ?

Thanks in advance

D

**FUNCTION**
Option Base 1
Function UniqueItems(ArrayIn, Optional Count As Variant) As Variant
Dim Unique() As Variant
Dim u() As Variant
Dim Element As Variant
Dim i As Integer
Dim FoundMatch As Boolean
Dim r As Range
Set r = Application.Caller
If IsMissing(Count) Then Count = True
NumUnique = 0
For Each Element In ArrayIn
FoundMatch = False
For i = 1 To NumUnique
If Element = Unique(i) Or Element = 0 Then
FoundMatch = True
GoTo AddItem
End If
Next i
AddItem:
If Not FoundMatch Then
NumUnique = NumUnique + 1
ReDim Preserve Unique(NumUnique)
Unique(NumUnique) = Element
End If
Next Element
If Count Then
UniqueItems = NumUnique
Else
If NumUnique r.Count Then
ReDim Preserve Unique(1 To r.Count)
Unique(UBound(Unique)) = (NumUnique - r.Count) + 1 & " more"
UniqueItems = Application.Transpose(Unique)
ElseIf NumUnique < r.Count Then
ReDim Preserve Unique(1 To r.Count)
For i = NumUnique + 1 To r.Count
Unique(i) = ""
Next
UniqueItems = Application.Transpose(Unique)
Else
UniqueItems = Application.Transpose(Unique)
End If
End If
End Function
 
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 change the macro called by an add in from older excel? Ian Excel Discussion (Misc queries) 2 June 25th 08 10:53 PM
What is this function called?? jPaulB Excel Discussion (Misc queries) 3 August 4th 06 08:33 PM
String function in C++ called from VBA MrT Excel Programming 0 December 28th 04 05:43 PM
XLA function called twice Nigel[_9_] Excel Programming 0 November 16th 04 10:46 AM
Possible to know who has called a function ? Isabelle Robin Excel Programming 3 March 5th 04 12:33 AM


All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"