#Value Error when calling VBA Function

hmltnangel

Active Member
Joined
Aug 25, 2010
Messages
290
Office Version
  1. 365
Platform
  1. Windows
Hi Excel people,

I have a Function in VBA that a formula is calling up. But its recently started just giving me a #Value error.Any suggestions?

VBA Function: (Is in a Module in VBA)

VBA Code:
Function MultipleLookupNoRept(Lookupvalue As String, LookupRange As Range, ColumnNumber As Integer)
Dim i As Long
Dim Result As String
For i = 1 To LookupRange.Columns(1).Cells.Count
  If LookupRange.Cells(i, 1) = Lookupvalue Then
    For J = 1 To i - 1
    If LookupRange.Cells(J, 1) = Lookupvalue Then
      If LookupRange.Cells(J, ColumnNumber) = LookupRange.Cells(i, ColumnNumber) Then
        GoTo Skip
      End If
    End If
    Next J
    Result = Result & " " & LookupRange.Cells(i, ColumnNumber) & ","
Skip:
  End If
Next i
MultipleLookupNoRept = Left(Result, Len(Result) - 1)
End Function

Then the formula is:

=MultipleLookupNoRept(A2,Resource,4)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
What is the address from the range RESOURCE?
 
Upvote 0
Thanks Mart,

Resource is a table called Resource on same tab as the formula, covering A1:D580
 
Upvote 0
Example:

The expected output would be

B2 - Blank
B3 - BB-BBI, BB-TBE
ABCD
1Staff IDCombined ProjectsNameProject
2123456=MultipleLookupNoRept(A2,Resource,4)Ed EddieBB - BBI
3123456=MultipleLookupNoRept(A3,Resource,4)Ed EddieBB - TBE
 
Upvote 0
I get no error.
Output is:
Staff IDCombined ProjectsNameProject
123456​
BB - BBI, BB - TBEEd EddieBB - BBI
123456​
BB - BBI, BB - TBEEd EddieBB - TBE
 
Upvote 0
That would be acceptable, but I get #Value!

What would cause the value error? Formatting somewhere?
 
Upvote 0
Resource is a table called Resource on same tab as the formula, covering A1:D580

Can you check the range. On the tab FORMULA is a button NAME MANAGER
 
Upvote 0
Solution
aaaahhhhh, now we might be somewhere.

In the Name Manager, the "Resource" name is there, but in the Value fields, theres "#N/A!" in some of the values
 
Upvote 0
And popping an "IFERROR" into the column causing the errors ...... makes it work fine :D

Thanks Mart would never have worked it out without that pointer.
 
Upvote 0

Forum statistics

Threads
1,215,566
Messages
6,125,593
Members
449,237
Latest member
Chase S

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