+ Reply to Thread
Results 1 to 4 of 4

VLookUp skipping empty cells

  1. #1
    Registered User
    Join Date
    10-28-2006
    Posts
    8

    VLookUp skipping empty cells

    Alright, I'm new to VBA and just back from a three day class. This is my first program ever in any language so dont be harsh on me, haha.

    So, I have two tables of data in two different sheets. They are financial time series, with the names of companies in the left most columns. I have written the following line of code that manages to find the row in which the company name appears, and get the data from the right column:

    PHP Code: 

    For 4 To 15

    Worksheets
    ("Differens").Cells(i1).Value Application.VLookup(Cells(i1), Range("SAF"), KFalse) - Application.VLookup(Cells(i1), Range("BUS"), LFalse)
        
    Next i

    End Sub 
    i j k l are all previously defined variables.

    the cells (i,1) after VLookUp is the value that it uses to find the correct row. The problem is that sometimes it doesnt find the value, which is fine, because sometimes the companies havent submitted their data yet.

    The question is though, how do I get it to simply skip that cell and move on to the next one? Right now I get an error message when I try to run the code and it stops at the row that has a name it cant find.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why do you feel it necessary to use VBA to achieve this ? A PivotTable would be much better.

    If you use VBA then use the .Find method instead of VLOOKUP
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-28-2006
    Posts
    8
    I'm familiar with pivot tables and believe me, it has to be done this way.

    I'll check out .find

  4. #4
    Registered User
    Join Date
    10-28-2006
    Posts
    8
    I got it to work, ignore this post.

+ 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