Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:07:42+00:00 2026-06-12T09:07:42+00:00

I have a method to execute a Distinct Result from a Table Column on

  • 0

I have a method to execute a Distinct Result from a Table Column on a Worksheet.

The result of the Method will go into a Data-Validation listbox in a cell. I have two needs right now that require me to "dummy mitigate" the method’s use, by limiting the number of columns passed to the method by one. This part i can get done, what i would like to do is have it so that if there are multiple columns in the Range, then it "pukes" on the user, stating that an illegal function call was made from "Worksheet"."Cell" and to alert the IT Support to resolve the problem.

Getting the Worksheet is great and the easy part. Its more of getting the reference to the Calling Cell without explicitely forcing the IT Support to pass the Cell as a value to the method.

Any ideas on how to extract the Calling Cell?

Ultimately this method will be used across several worksheets to perform the same logic with different ranges being passed to it.

Edited 2012-09-24 10:30am CST

Here is my implementation so far, havent utilized the Application.Caller method into it.

Function UniqueValues(ws As Worksheet, col As String) As Variant

   Dim rng As Range: Set rng = ws.Range(col)
   Dim dict As New Scripting.Dictionary
   
   If Not (rng Is Nothing) Then
      Dim cell As Range, val As String
      
      For Each cell In rng.Cells
         val = CStr(cell.Value)
         
         If Not dict.Exists(val) Then
            dict.Add val, val
         End If
         
      Next cell
   End If
      
   'Return value
   UniqueValues = dict.Items
End Function

This method is already being used in code-behind logic. I will be copying this logic and making it apart of the Application.Volatile segment for the Excel Workbook i am working on. Will be similar but not the same.

Here is the current design, not much but what i am workgin with atm.

Function DistinctValues(rng As Range)
Application.Volatile True
    If rng.Columns.Count > 1 Then
        Err.Raise -1542376, rng.Worksheet.name, "An invalid function call was made!"
    End If
    
    
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:07:43+00:00Added an answer on June 12, 2026 at 9:07 am

    Application.Caller returns the cell that called a function. See this MSDN definition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Button which when clicked will execute an addQty method and in
I have a data table I've loaded from a CSV file. I need to
I have a particularly long running method that I need to execute from my
I have a method that will execute a query with a list of QueryParameters
I have an abstract class with some methods,including an abstract method(Execute()).This method is overridden
I have a service class that I need to execute a method on a
I have some code in method C that will get executed based upon the
I have a form validation method that's called on submit. It executes a get
It looks like #temptables created using dynamic SQL via the EXECUTE string method have
I have a method that takes a callback argument to execute asynchronously, but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.