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]
99 questions
0
votes
1 answer
#VALUE Error on Custom Function
Function HasStrike(Rng as Range) As Boolean
HasStrike = Rng.Font.Strikethrough
End Function
I am using a custom function to see if a column has a strikethrough. If the column has a strikethrough, it returns a boolean and I delete the row. However,…

kmiao91
- 303
- 4
- 11
- 22
0
votes
1 answer
SQLSTATE=39501 while using UDF with Excel for DB2
I am trying to get data from excel into a db2 database to then export that to ixf.
Here is the source (ddl file)
connect to MYDB
drop function ARTIKEL_MATNR;
CREATE FUNCTION ARTIKEL_MATNR()
RETURNS TABLE(Material VARCHAR(64), HerstellerteileNr…

Thevagabond
- 323
- 2
- 9
- 34
0
votes
2 answers
VBA - Find certain strings in a worksheet
I want to create either a macro or a UDF that can find cells in an excel worksheet that contains the following:
POxxx
PO xxxxxxx
PO# xxxxx
PO#xxxx
(With x being numbers)
The string could be at the start or the middle of cells.
In addition, the…
user4458786
0
votes
1 answer
excel UDF doesn't work when used in sheet
I created a function that is working when activated through a sub in my workbook, but when trying to activate it in a worksheet (using =function_name(arguments))
Function calclkg(Optional table_name As String = "lkg_calc_params", Optional ByVal…

ohadnach
- 1
0
votes
1 answer
#VALUE error when dealing with long string in UDF in VBA(excel)
I've encountered #VALUE error when using an UDF returning an array with long strings (>256 symbols).
Sample Code:
Function longString() As Variant
Dim res(1 To 1, 1 To 2)
res(1, 1) =…

Terence Hang
- 207
- 1
- 9
0
votes
1 answer
Formulas w/ Custom Functions work fine but then turn into #Value error
I have a colleague who is on Excel 2003. I made some custom functions for him, in an .xla add-in. He was having too much trouble around the path issues of custom functions in add-ins, so I moved the custom functions to a workbook, and he makes…

Greg Lovern
- 958
- 4
- 18
- 36
0
votes
2 answers
Using UDF Returned Value in Worksheet Function
I have created a UDF that returns the last populated row in a specific column. Right now, it returns the row number of the last populated row. My question is, how would I go about using this value in a worksheet function?
For example,…

Mayur Saxena
- 3
- 2
0
votes
1 answer
UDF causing Lag
Thanks to the answer from Noodles I know that my UDF is the main cause of lag in my excel workbook. Can this UDF be re-written to not cause the lag? I am using this UDF with an excel formula (example =IF(OR(ISNUMBER($DH2),$DH2>"…

user3554998
- 19
- 9
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 :…

user270576
- 987
- 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

axmz
- 29
- 1
- 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?

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…

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

Nam G VU
- 33,193
- 69
- 233
- 372