+ Reply to Thread
Results 1 to 5 of 5

I couldn't get the row number based on my search value.

  1. #1
    Registered User
    Join Date
    08-10-2020
    Location
    Chennai
    MS-Off Ver
    2006
    Posts
    4

    I couldn't get the row number based on my search value.

    Hello All,

    I am a new member to this forum. Please help me on the below issues.

    findadjrow = ThisWorkbook.Sheets("sheet1").Range("D" & n & ":D" & findaggvalue).Find(What:="N", SearchOrder:=xlByRows).Row

    I just wanted to get the row number based on the character "N" that available in the sheet1. The "N" available more than one occurrence in the sheet1, once I got the row number of "N", I have to perform some math operations. But the above code didn't return the row number of "N", instead it return the next row number.
    I confirmed it through MsgBox function. Basically macro couldn't locate the value "N", but if append another character with N, like "NY" its working well. Please help me to fix this issue.

    Thanks in Advance!
    Last edited by sriramr13; 08-21-2020 at 09:32 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: I couldn't get the row number based on my search value.

    try including the LookAt argument, if you are trying to find cell that only contains "N"

    lookat:=xlWhole
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-10-2020
    Location
    Chennai
    MS-Off Ver
    2006
    Posts
    4

    Re: I couldn't get the row number based on my search value.

    Thanks Andy!

    I tried the above using LookAt. But I getting error "Object variable or With block variable not set"

    findadjrow = ThisWorkbook.Sheets("sheet1").Range("D" & n & ":D" & findaggvalue).Find(What:="N", LookAt:=xlWhole, SearchOrder:=xlByRows).Row

    Could you please tell me how to fix this?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: I couldn't get the row number based on my search value.

    You need to post example workbook as the syntax works.
    We need to see what's on the worksheet, what the values of n and findaggvalue are.

    And I assume your post with Rowb as the return value is a typo?

  5. #5
    Registered User
    Join Date
    08-10-2020
    Location
    Chennai
    MS-Off Ver
    2006
    Posts
    4

    Re: I couldn't get the row number based on my search value.

    Thank you Andy!

    It worked well after adding the LooIn: parameter along with LooAt:

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to resolve Data FormatError We couldn't convert it to Number-Power Query
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-25-2019, 01:16 AM
  2. Search through a number of excel surveys for information based on keywords. help!
    By imadoofus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2016, 01:12 AM
  3. Looking for code to search web based on value and return phone number
    By JeremyBoston in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-19-2015, 03:39 PM
  4. Replies: 1
    Last Post: 02-05-2015, 05:44 PM
  5. VBA Code - Search text & search number & search qty and result - Urgent Please
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2014, 10:51 AM
  6. Updating a particular row number based on search
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-16-2010, 08:38 PM
  7. Replies: 1
    Last Post: 12-21-2005, 12:10 PM

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