Hi All,
I have a small VBA function in one of my excel spreadsheets (a simple version of it is pasted below. I pass a part number to this function and it runs through another sheet and collects all instances of this part number.
If I call the procedure via a command button.....
call part("partnumber")
....then the function runs perfectly.
But when I try to call the procedure via a formula....
=part(c16)
.....(where C16 is the cell with the part number) the function doesn't work, it doesn't find anything even though partnumber variable is being passed correctly.
Has anyone seen anything like this before?
Gareth
I have a small VBA function in one of my excel spreadsheets (a simple version of it is pasted below. I pass a part number to this function and it runs through another sheet and collects all instances of this part number.
If I call the procedure via a command button.....
call part("partnumber")
....then the function runs perfectly.
But when I try to call the procedure via a formula....
=part(c16)
.....(where C16 is the cell with the part number) the function doesn't work, it doesn't find anything even though partnumber variable is being passed correctly.
Has anyone seen anything like this before?
Gareth
Code:
Public Function part(partnumber As String)
If partnumber = "" Then
MsgBox "No part entered"
Exit Function
End If
With Worksheets("rawpartdata").Range("A1:A1000")
Set partfind = .Find(partnumber, LookIn:=xlValues)
If partfind Is Nothing Then
MsgBox "Invalid Part Number"
Exit Function
Else
stractiverow = partfind.Row
End If
End With
End Function