User-defined functions (UDFs) are VBA procedures that typically take inputs (although inputs are not mandatory) to return a result to either a worksheet cell, or to another VBA procedure. By design UDF's that are called from a worksheet should only return a value to the cell from where the function was called - the UDF should not modify the contents or formatting of any cell, or the operating environment of Excel (there are workarounds to this design).
Questions tagged [excel-udf]
90 questions
0
votes
1 answer
Using PublishObject.Publish() in background thread resets workbook's calculation mode
I'm creating an Excel Add-in that implements IDTExtensibility2 and has one function that publishes a range off the worksheet using Excel's PublishObjects
I'm using Visual Studio 2008 and Excel 2007, the following is my code:
public class AddIn :…
![](../../users/profiles/270576.webp)
user270576
- 937
- 10
- 16
0
votes
2 answers
Nested if statement within a for loop
I am modifying a User Defined Function which I wrote. It removes special characters from a cell (I have posted about this same function a handful of times, as I keep expanding it and learning more about the capabilites of VBA).
What I am trying to…
user2993456
0
votes
1 answer
Excel UDF to count errors
I was trying to write an UDF in Excel VBA which would count errors (#NA!, #REF!...).
I tried to translate Excel formulas into VBA language bud did not succed.
Does somebody know a solution?
Thanks
![](../../users/profiles/2983572.webp)
axmz
- 29
- 5
0
votes
1 answer
Excel VBA UDF that return value will override itself
Can I write a UDF in Excel VBA where the return value from the function will override the cell value from it is called from?
The function get information with a sql request. In this case it's only master data for example the item description. If the…
0
votes
1 answer
Argument type validation in the Function Wizard
In Excel, the DATE function for example shows "=number" against each field.
If I enter a string in these fields in place of a number, I get the #VALUE! error.
Can similar functionality be achieved with Excel-DNA?
![](../../users/profiles/1686833.webp)
TheCodeMan
- 1
- 2
0
votes
1 answer
Find current column for Excel automation add-in
I am trying to create Excel Automation Add-ins with C# to add new functions to Excel. Like this example: http://blogs.msdn.com/b/eric_carter/archive/2004/12/01/273127.aspx
I am quite new to programming such add-ins.
One of these functions calculates…
![](../../users/profiles/2409060.webp)
Frode
- 1
0
votes
1 answer
VBA user-defined function to copy value, text formation and hyperlink of a cell?
Given a sample plain excel file here, what is the VBA code to copy value, formation and hyperlink of a cell?
i.e. At cell B5 we will call =myCopyCellFunction(B2) and we will get the exact cell value at B2
![](../../users/profiles/248616.webp)
Nam G VU
- 28,311
- 62
- 206
- 338
-1
votes
1 answer
Excel Formula to type in numeric value of green cells in the same row
I would like some help in entering a formula in excel VBA I assume to enter all numbers of a certain highlighted color (green in this case) in a different column but is in the same row within a column range.
Excel Table 1
To help make things…
![](../../users/profiles/6877165.webp)
Yousef Alkaff
- 3
- 2
-1
votes
2 answers
Creating UDF using VBA in excel to find similar values in a row where order does not matter
I am dealing with unlimited new rows of data every day and I need a UDF that would find similar row values regardless of its order. As you can see in the example bellow A9:F9 and A4:F4 has a similar row values marked as SIMILAR ROW 1. You need to…
![](../../users/profiles/6194309.webp)
Egie Boy Aguspina
- 31
- 7
-1
votes
1 answer
Find average of top and bottom n percent of range with extra condition
Example:
Part, Qty
Book, 1
Book, 2
Book, 3
Book, 4
Book, 5
Book, 6
Book, 7
Book, 8
Book, 9
Book, 10
Pen, 4
Pen, 7
I'm trying to calculate the book qty average of top 10% in the range B:B.
Tried getting it to work with an…
![](../../users/profiles/2886222.webp)
Ruben
- 3
- 3
-1
votes
1 answer
VBA Excel: User Defined Function
FIXED: check user3964075's comment
Need help with my simple code below:
it's basically a different version of vlookup where you can also specify which row to look for.
asda(fval, rng, fcol, rcol)
fval is what the user is looking for
rng is the…
![](../../users/profiles/4953179.webp)
hakusai
- 3
- 2
-2
votes
1 answer
Limits reached in INDEX(MATCH()) when taking array as argument to look in
I use this formula:
=IFERROR(IF(MATCH(transf(E7);transf(Sheet2!$C$2:$C$66648);0)>0;"YES");"no")
transf is a UDF which simply converts/transforms the actual text value in cell to lowercase and does some other stuff (not the subject for this…
![](../../users/profiles/2753501.webp)
ZygD
- 8,011
- 21
- 49
- 67
-2
votes
3 answers
Way too long of a function but I need it - can it be done in VBA?
Because of severe lack of knowledge, I made a ridiculously long function so that I could make my calculation. The problem is that it is too long for Excel, and I tried looking online to see how I could maybe make a new function in VBA that…
![](../../users/profiles/4657988.webp)
Erik
- 13
- 1
- 4
-3
votes
3 answers
Returning values if it is greater than and less than to a specific value using UDF
I am currently working on a UDF which returns and concatenates the headers if it is greater than and less than to a specific value. I’m not really good in Excel-Vba and what I got so far is this pathetic code which I couldn’t understand anymore. I…
![](../../users/profiles/6229436.webp)
Rakushoe
- 99
- 10
-3
votes
1 answer
Macros causing Lag
I am running a program that uses 5 macros and lots of formulas. Some of the macros I have asked for your help on here. After putting the program together there is alot of lag. I mean if we delete a line we have to wait 1 to 2 minutes for it do…
![](../../users/profiles/3554998.webp)
user3554998
- 19
- 9