+ Reply to Thread
Results 1 to 2 of 2

blank cells for specific row only

  1. #1
    Registered User
    Join Date
    03-02-2007
    Posts
    21

    blank cells for specific column only

    Hi all,

    Have read the forums and understand that there is a piece of code that works very well for looping and stopping at a blank cell as follows:-

    MyLastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Row

    However I have two columns, one with a list of items and a second column next to it that has a formula that will pick up a vlookup reference, if it cannot find it then it leaves a blank cell ("").

    This is a formula that is copied down all rows where it is possible to enter items.

    Perhaps an example explains it better:-

    Column1..........Column2
    123................=if(isna(vlookup(r2c1,range,2,0)),"",vlookup(r2c1,range,2,0))
    234................=if(isna(vlookup(r3c1,range,2,0)),"",vlookup(r2c1,range,2,0))
    blank..............=if(isna(vlookup(r4c1,range,2,0)),"",vlookup(r2c1,range,2,0))
    ....................etc

    (sorry spaces not showing hence the ...)

    Now the problem is the MyLastRow appears to look in column 2 for the last cell before a blank and not column 1. As Column 1 is actually being used to pick up an image it fails once it hits a blank.

    Hope that makes sense. I want the last row return to be defined from column 1 only.

    Thanks.
    Last edited by GBoy; 03-12-2007 at 08:05 PM. Reason: title was incorrect and said row not column

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    You are mistaken what the find command does.

    It finds the last cell that has an entry on it on the activesheet and supplies the row number of that cell to the MyLastRow variable. It does not find blank cells.

    Here are some different methods to find rows & columns

    In all cases you will need to add 1 to the result to get the blank cells row or column number

    Please Login or Register  to view this content.
    Please read posting rules - see red link below
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

+ 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