Custom Function Returning #VALUE!

ExperTeece

New Member
Joined
Sep 19, 2012
Messages
6
I have created a custom function do perform concatenation of 16 cells that may not all have values in them. The first cell is required so I pass its value seperately. The remainder I pass as a range. The function works fine during testing but then once I save the file and reopen it the function ends up with the #VALUE! error. I have somewhat resolved the issue by putting a default value in the first cell rather than leaving it blank but would really like to figure out why the function is not working. Thanks in advance for any answers you may have. Below is the code:
Code:
Function DescBuild(Optional Class As String, Optional AttRng As Range) As String
Dim FinalString As String
Dim attCnt As Integer
 
DescBuild = ""
FinalString = ""
'If Class = "" Then
 '   GoTo MyExit
'End If
FinalString = Class
For attCnt = 1 To 15
    If Not AttRng(attCnt).Value = "" Then
        FinalString = FinalString & ", " & AttRng(attCnt).Value
    End If
Next
MyExit:
DescBuild = FinalString
End Function
 
That is odd....Using the version in the OP, try the formula =DescBuild(B6&"", B7:B21). That will at least coerce the first argument into being a string.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
While this does not answer the question you asked, you may find the UDF that I posted here of some interest (it is a concatenation program with additional functionality)...

Flexible Concatenation Function

Rick,
Thanks for the function. Using it instead of mine has solved my issue for now. I still want to figure out why my function did not work as expected, but at least I can get my tool out to my end user group.

Dave
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top