none
vba .find sintax RRS feed

  • Question

  • I am trying use vba to search for a specific text within a worksheet. The command I am trying to use is:

    Set c_Search = searchrange.Find("NOTES", LookIn:=xlValues, LookAt:=xlPart)

    The value of xlValues is -4163, xlPart is 2 and c_Search is dimentioned as a range searchrange and is set to "A2:F500".

    It responds with Nothing into c_Search.

    Does it need a worksheet to be active for it to work? What am I missing?

    Wednesday, November 26, 2014 10:10 PM

Answers

  • Perhaps you need to specify that the search will be case-insensitive:

    Set c_Search = searchrange.Find(What:="NOTES", LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, November 26, 2014 10:50 PM
  • RE:  "Does it need a worksheet to be active for it to work?"

    Answer:  Yes
    Also adding...  "MatchCase:=False"   would probably help.

    '---
    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    Wednesday, November 26, 2014 10:59 PM

All replies

  • Perhaps you need to specify that the search will be case-insensitive:

    Set c_Search = searchrange.Find(What:="NOTES", LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, November 26, 2014 10:50 PM
  • RE:  "Does it need a worksheet to be active for it to work?"

    Answer:  Yes
    Also adding...  "MatchCase:=False"   would probably help.

    '---
    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    Wednesday, November 26, 2014 10:59 PM