Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Function to find value in string

Hi can someone help with this funtion
if the cell selected as the input for the function is 123'150
then I would expect this to return 150
Public Function rev32(Price As String)
'=RIGHT(J5,LEN(J5)-FIND("'",J5))
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))

End Function

I get a REF error
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Function to find value in string

Works for me. Check whether you have placed the function in the proper
place..From workbook launch VBE using Alt+F11. From menu Insert a Module and
paste the below function.Close and get back to workbook and try the below
formula. Make sure the module is within the same workbook

Public Function rev32(Price As String)
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))
End Function

Alternatively you can try
rev32 = Mid(Price, InStr(Price, "'")+1)
OR
rev32 = Split(Price, "'")(1)


If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

Hi can someone help with this funtion
if the cell selected as the input for the function is 123'150
then I would expect this to return 150
Public Function rev32(Price As String)
'=RIGHT(J5,LEN(J5)-FIND("'",J5))
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))

End Function

I get a REF error

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Function to find value in string

wow most annoying thing ever... tried in new workbook, closing excel,
strange... I have no idea if it works for you...

"Jacob Skaria" wrote:

Works for me. Check whether you have placed the function in the proper
place..From workbook launch VBE using Alt+F11. From menu Insert a Module and
paste the below function.Close and get back to workbook and try the below
formula. Make sure the module is within the same workbook

Public Function rev32(Price As String)
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))
End Function

Alternatively you can try
rev32 = Mid(Price, InStr(Price, "'")+1)
OR
rev32 = Split(Price, "'")(1)


If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

Hi can someone help with this funtion
if the cell selected as the input for the function is 123'150
then I would expect this to return 150
Public Function rev32(Price As String)
'=RIGHT(J5,LEN(J5)-FIND("'",J5))
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))

End Function

I get a REF error

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Function to find value in string

Yes as Niek mentioned i tried this in 2003...and hence working..It is
considered as a good programming practice to name your funcitons and
procedures to reflect what they do..like

GetValuefromString()

"John" wrote:

wow most annoying thing ever... tried in new workbook, closing excel,
strange... I have no idea if it works for you...

"Jacob Skaria" wrote:

Works for me. Check whether you have placed the function in the proper
place..From workbook launch VBE using Alt+F11. From menu Insert a Module and
paste the below function.Close and get back to workbook and try the below
formula. Make sure the module is within the same workbook

Public Function rev32(Price As String)
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))
End Function

Alternatively you can try
rev32 = Mid(Price, InStr(Price, "'")+1)
OR
rev32 = Split(Price, "'")(1)


If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

Hi can someone help with this funtion
if the cell selected as the input for the function is 123'150
then I would expect this to return 150
Public Function rev32(Price As String)
'=RIGHT(J5,LEN(J5)-FIND("'",J5))
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))

End Function

I get a REF error

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Function to find value in string

If you happen to use Excel2007 (or even 2010), then REV32 is not a valid
function name, because it is a cell address.
If you change the function name you'll see your function working as
expected.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"John" wrote in message
...
Hi can someone help with this funtion
if the cell selected as the input for the function is 123'150
then I would expect this to return 150
Public Function rev32(Price As String)
'=RIGHT(J5,LEN(J5)-FIND("'",J5))
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))

End Function

I get a REF error




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Function to find value in string

thank you for the help :)

"Niek Otten" wrote:

If you happen to use Excel2007 (or even 2010), then REV32 is not a valid
function name, because it is a cell address.
If you change the function name you'll see your function working as
expected.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"John" wrote in message
...
Hi can someone help with this funtion
if the cell selected as the input for the function is 123'150
then I would expect this to return 150
Public Function rev32(Price As String)
'=RIGHT(J5,LEN(J5)-FIND("'",J5))
rev32 = Right(Price, Len(Price) - InStr(Price, "'"))

End Function

I get a REF error


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
EXCEL function;find string in entire column & return cell referenc Audit Compliance Man Excel Worksheet Functions 2 April 21st 23 10:24 AM
Function to read text file; find string; delete same before import [email protected] Excel Programming 32 August 5th 08 10:50 PM
Find String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM


All times are GMT +1. The time now is 12:04 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"