+ Reply to Thread
Results 1 to 7 of 7

"find" method malfunction when filter is applied

Hybrid View

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    CZ, EU
    MS-Off Ver
    2010/2016
    Posts
    31

    "find" method malfunction when filter is applied

    Hello,

    This code:

        LastCellE = ThisWorkbook.Worksheets(idx1).Range("E4:E3003"). _
                   Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    works well until filter is applied to column E (which results in hiding some rows...). Then it works incorrectly. The code simply finds the last row with non-empty cell in column E.

    Any suggestion? Thanks.

    (E-column cells contain matrix formula)

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: "find" method malfunction when filter is applied

    Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    finds the last row in sheet, not column E only, i.e. whatever column has the lowest(Longest) data.

    If you want to find the last row in column E, you should use

    Lastrow= Range("E"&rows.count).end(xlup).row

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    CZ, EU
    MS-Off Ver
    2010/2016
    Posts
    31

    Re: "find" method malfunction when filter is applied

    As you can see, I begin with "ThisWorkbook.Worksheets(idx1).Range("E4:E3003"). " which limits the search only to column E.
    Try end(xlup) and you will see, that it also does not work, when some rows are filtered (= not displayed).
    Furthermore, end(xlup) will not ignore blank cells containing formulas (= no values, just formulas).
    But thanks.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: "find" method malfunction when filter is applied

    You have not mentioned what kind of error you are getting and in which line of the code the error occurs?
    Last edited by AB33; 10-14-2013 at 07:30 AM.

  5. #5
    Registered User
    Join Date
    05-07-2013
    Location
    CZ, EU
    MS-Off Ver
    2010/2016
    Posts
    31

    Re: "find" method malfunction when filter is applied

    This dynamic range evaluation should speed up data processing by limiting calculation only to relevant rows. There are thousands of rows on several worksheets.

  6. #6
    Registered User
    Join Date
    05-07-2013
    Location
    CZ, EU
    MS-Off Ver
    2010/2016
    Posts
    31

    Re: "find" method malfunction when filter is applied

    There is no error, just evaluation of the last non-blank E-cell is incorrect, when filtering is applied (which I verified using "add watch" while debugging). I'm just trying to set dynamic range depending on the last non-blank E-cell... for further processing of data in other columns on several worksheets across workbook...

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: "find" method malfunction when filter is applied

    Lastrow=Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Finds the last row in all columns(All columns in a sheet)

    Lastrow= Range("E"&rows.count).end(xlup).row
    Finds the last row in a single column "E" ONLY

+ 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. Replies: 2
    Last Post: 09-25-2012, 12:53 AM
  2. "The "sheets" method from the "_Global" object have failed."
    By mankit87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2011, 08:53 AM
  3. [SOLVED] Find method fails in Excel 2003 ("Subscript out of range")
    By Guy Jara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2006, 12:10 AM
  4. What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 PM
  5. "find" and "filter" working weirdly
    By weiin t via OfficeKB.com in forum Excel General
    Replies: 1
    Last Post: 02-18-2005, 07:06 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