+ Reply to Thread
Results 1 to 3 of 3

Find last row using xlUp with value, not just formula

Hybrid View

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Find last row using xlUp with value, not just formula

    Hi,

    Trying to erase everything in Column D that comes after a final value in Column B using the following in VBA:

    lastrow=Range("B700".End(xlUp).Row+1
    Range("D700:D"&last row).ClearContents
    Before I reach what is probably a concatenation problem (can you erase with backwards range?), the xlUP function is giving an unwanted value because the entirety of Column B has an if statement in it. So while some cells show up blank (as indicated in the If), they are not in fact empty.

    Any ideas of a workaround? Do not know how to do something similar to xlUp just to a cell with content in order to achieve what I want.

    Thanks.

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Find last row using xlUp with value, not just formula

    Maybe something like:

    LastRow = Range("B:B").Find("*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    With or without a "+ 1" at the end.

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Find last row using xlUp with value, not just formula

    Nice - that's very clever! Thanks.

+ 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