+ Reply to Thread
Results 1 to 3 of 3

Defining Find Function

  1. #1
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    171

    Defining Find Function

    Hi,

    Im trying to creating functions to find variables,
    the below isnt quite working, many thanks


    Function finrows(x As String)


    Cells.FIND(What:="x", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
    End Function


    Function fincols(x As String)


    Cells.FIND(What:="x", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
    End Function

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Hmm, strange. It doesn't seem to be possible to use the Find command within a function. If you're trying to return the row/column number of something within a macro, you could use a module level variable to hold the value. This defines a routine "find_row_or_column" to return the row (default or "return_column" = False) or column ("return_column" = True or <> 0), or 0 if not found, to the variable "found_row_or_column":

    Please Login or Register  to view this content.
    To return this from a UDF usable within a worksheet would probably involve spanning the usedrange a cell at a time...


    Col
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  3. #3
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Find started working in xl2002. Before that, it didn't work in UDFs.

    HTH
    Cheers
    Carim

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1