Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
nc
 
Posts: n/a
Default Writting Function using VBA

Hi

I am trying to write a function to return an address but
instead I get #VALUE!.

Public Function fnd(a, b)

fnd = Range(a).Find(b).Address

End Function


Please help.

Thanks.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

..Find won't work in UDF's called from the worksheet until xl2002.

Depending on the range (a), you could use application.match() through each
column.

If the range is small, you could just loop through the values in that range,
too.

nc wrote:

Hi

I am trying to write a function to return an address but
instead I get #VALUE!.

Public Function fnd(a, b)

fnd = Range(a).Find(b).Address

End Function

Please help.

Thanks.


--

Dave Peterson
  #3   Report Post  
nc
 
Posts: n/a
Default

Hi Dave

Thanks for your response.

I am using Excel 2003.


-----Original Message-----
..Find won't work in UDF's called from the worksheet

until xl2002.

Depending on the range (a), you could use

application.match() through each
column.

If the range is small, you could just loop through the

values in that range,
too.

nc wrote:

Hi

I am trying to write a function to return an address

but
instead I get #VALUE!.

Public Function fnd(a, b)

fnd = Range(a).Find(b).Address

End Function

Please help.

Thanks.


--

Dave Peterson
.

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

This worked ok for me (also xl2003):

Option Explicit
Public Function fnd(a, b)
Dim FoundCell As Range

Set FoundCell = Range(a).Find(b)
If FoundCell Is Nothing Then
fnd = "Not Found"
Else
fnd = FoundCell.Address
End If

End Function

I used this in the cell:
=fnd("B1:B99",A1)

===
I think I'd also specify all the parameters in the .find statement. .Find
remembers all the ones you previously set--manually or via code.

nc wrote:

Hi

I am trying to write a function to return an address but
instead I get #VALUE!.

Public Function fnd(a, b)

fnd = Range(a).Find(b).Address

End Function

Please help.

Thanks.


--

Dave Peterson
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
Need a ISWorkday Function -- Any Ideas Mark Excel Worksheet Functions 5 March 29th 05 01:58 AM
Hyperlinks using R[1]C[1] and offset function in its cell referenc Elijah-Dadda Excel Worksheet Functions 0 March 5th 05 03:31 AM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
Trim function doesn't clean out ASCII Code 160 (Space) Ronald Dodge Excel Worksheet Functions 6 January 27th 05 03:48 AM
Formula to list unique values JaneC Excel Worksheet Functions 4 December 10th 04 12:25 AM


All times are GMT +1. The time now is 07:37 PM.

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

About Us

"It's about Microsoft Excel"