+ Reply to Thread
Results 1 to 2 of 2

Placing a vlookup formula within a cell in VBA

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Placing a vlookup formula within a cell in VBA

    Hi

    does anyone know hwo to place a vlookup formula in a cell range using macro?

    As i have a loop which loops through a cell range using the value in the cell to create the vlookup forumla to be placed in a cell in a seperate sheet. However this birngs an error of "Application-defined or Object defined error"

    [/code]
    For Each cell In PPNewIR.Range("A1:A3000")
    If cell.Value <> "" Then
    PPNewIR.cells(Nrow, 6).Value = Application.WorksheetFunction.VLookup(cell, PPNew.Sheets("ConvertManual").Range(""), 6, False)
    End If
    Application.StatusBar = cell.Address
    Next cell
    [/code]

    If anyone could help that would be great

    thanks

    jeskit

    Edit: i found the solution to that error put data range in which A1:Y3000......However now when i run it i get an error message saying "unable to get the vlookup property of the worksheetfunction class"
    Last edited by jeskit; 05-05-2011 at 09:16 AM.

  2. #2
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: Placing a vlookup formula within a cell in VBA

    Are you sure that the vlookup formula will return a result. I've often found this error so before even attempting a vlookup, I will usually do a countif to see if the value im looking up is actually in the range..

    if that makes sense.. :-)

+ 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