Results 1 to 7 of 7

vlookup problem and count problem

Threaded View

  1. #1
    Registered User
    Join Date
    05-28-2009
    Location
    Hong Kong
    MS-Off Ver
    Excel 2003
    Posts
    11

    vlookup problem and count problem

    I try the nested for-loop at the past, but data checking is time consuming. So I decide to use vlookup to compare and get the data from another worksheet. I have searched many samples which is only for one workbook. In my code, the variable 'found' get error result, all values are display "NULL".

    Please help to solve it...thank you!

    Sub marco()
    Dim rn As Integer
    Dim x As Integer
    Dim findmain As Variant
    Dim found As Variant
    Dim r As Range
    
        Workbooks.Open ("c:\ABC.xls")
        Workbooks("ABC.xls").Sheets(1).Range("a1:iv65536").Copy
        ThisWorkbook.Sheets(1).Range("a1").PasteSpecial
        Workbooks.Open ("c:\AA.xls")
        Workbooks("AA.xls").Sheets(1).Range("a1:iv65536").Copy
        ThisWorkbook.Sheets(2).Range("a1").PasteSpecial
        rn = 3930   
        rn2 = 12613 
       
        x = 4
    
     For i = x To rn
      findmain = ThisWorkbook.Sheets(1).Cells(x, 3)
      Set r = ThisWorkbook.Sheets(2).UsedRange
      found = Application.VLookup(findmain, r, 11, 0)
      If IsError(found) Then
        ThisWorkbook.Sheets(1).Cells(x, 26) = "NULL"
      Else: ThisWorkbook.Sheets(1).Cells(x, 26) = found
      End If
          x = x + 1
     Next i
    Attached Files Attached Files
    Last edited by thy00123; 06-05-2009 at 06:41 AM.

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