Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default formula works, functionworks, but not together

I have a formula that works when referencing a specific cell
=VLOOKUP(B13,ProjectUpset,3,FALSE) -in this case I've entered
"0-9876-10" into the cell

I have a custom function that correctly parses information form a string...
=findstring(B13) -in this case, the cell contains "Total 0-9876-10
Personal/Religious", and is parsed to return a value of "0-9876-10"

the function's code is:
Public Function Findstring(vCell)
Dim vStr As String
vStr = ""
Dim vEndNumber As Long

On Error Resume Next
vStr = Mid(vCell.Value, 7, Len(vCell.Value) - 7)
vEndNumber = InStr(1, vStr, " ")
Findstring = Mid(vStr, 1, vEndNumber)
End Function

however, when I insert the function into the formula, I get a #N/A
=VLOOKUP(findstring(B13),ProjectUpset,3,FALSE) - in this case, the cell
contains "Total 0-9876-10 Personal/Religious"


so, I'm confused; and any suggestions would be greatly appreciated
thanks in advance,
mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default formula works, functionworks, but not together

On Mon, 15 Dec 2008 19:25:30 -0500, "Mark Kubicki"
wrote:

I have a formula that works when referencing a specific cell
=VLOOKUP(B13,ProjectUpset,3,FALSE) -in this case I've entered
"0-9876-10" into the cell

I have a custom function that correctly parses information form a string...
=findstring(B13) -in this case, the cell contains "Total 0-9876-10
Personal/Religious", and is parsed to return a value of "0-9876-10"

the function's code is:
Public Function Findstring(vCell)
Dim vStr As String
vStr = ""
Dim vEndNumber As Long

On Error Resume Next
vStr = Mid(vCell.Value, 7, Len(vCell.Value) - 7)
vEndNumber = InStr(1, vStr, " ")
Findstring = Mid(vStr, 1, vEndNumber)
End Function

however, when I insert the function into the formula, I get a #N/A
=VLOOKUP(findstring(B13),ProjectUpset,3,FALSE) - in this case, the cell
contains "Total 0-9876-10 Personal/Religious"


so, I'm confused; and any suggestions would be greatly appreciated
thanks in advance,
mark


Most likely, your Findstring function is returning a trailing space appended to
the value, so the values are not what you think they should be.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default formula works, functionworks, but not together

Your function is returning 0-9876-10 (with a trialing space like Ron said).
to remove the trailing space make this change

from
vEndNumber = InStr(1, vStr, " ")

to
vEndNumber = InStr(1, vStr, " ") - 1



"Ron Rosenfeld" wrote:

On Mon, 15 Dec 2008 19:25:30 -0500, "Mark Kubicki"
wrote:

I have a formula that works when referencing a specific cell
=VLOOKUP(B13,ProjectUpset,3,FALSE) -in this case I've entered
"0-9876-10" into the cell

I have a custom function that correctly parses information form a string...
=findstring(B13) -in this case, the cell contains "Total 0-9876-10
Personal/Religious", and is parsed to return a value of "0-9876-10"

the function's code is:
Public Function Findstring(vCell)
Dim vStr As String
vStr = ""
Dim vEndNumber As Long

On Error Resume Next
vStr = Mid(vCell.Value, 7, Len(vCell.Value) - 7)
vEndNumber = InStr(1, vStr, " ")
Findstring = Mid(vStr, 1, vEndNumber)
End Function

however, when I insert the function into the formula, I get a #N/A
=VLOOKUP(findstring(B13),ProjectUpset,3,FALSE) - in this case, the cell
contains "Total 0-9876-10 Personal/Religious"


so, I'm confused; and any suggestions would be greatly appreciated
thanks in advance,
mark


Most likely, your Findstring function is returning a trailing space appended to
the value, so the values are not what you think they should be.
--ron

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Bar works smreilly Excel Discussion (Misc queries) 1 January 23rd 09 09:33 PM
Formula works but formula shows in cell??? Donald King Excel Worksheet Functions 2 October 30th 06 08:54 PM
Macros: Step Thru Works, Run Works, Keyboard Shortcut Locks up BEEJAY Excel Programming 2 October 3rd 06 06:46 PM
IF formula works one way and not the other Joe Gieder Excel Worksheet Functions 1 November 3rd 05 11:46 PM
Formula Works Only Sometimes??? Nick Excel Worksheet Functions 3 April 18th 05 08:21 PM


All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"