Results 1 to 9 of 9

Thread: Use Native Excel Function Lookup Formula In VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Use Native Excel Function Lookup Formula In VBA

    Hi,

    I have a query on VBA.

    There is a range of cells contains the following words (F4 to F19)

    Bridal
    Bars
    Body Polishing
    Clinics
    Android
    Comics
    Lighting
    Android
    Crystals
    Grocery
    Waxing
    Labs
    Flip Phones
    Drama
    Timer
    Flip Phones

    There is a sentance 'Aluminium Yoga Bridal Dealers Waxing' in A2


    If i try it out in Excel function, i can get the data through the following Excel function
    =LOOKUP(2^15,SEARCH(F4:F19,A2),F4:F19)

    But when i tried to convert it to the VBA, i receive 'Type mismatch error'

    Im not sure where im going wrong.

    I have mentioned the code.

    Code:
    Sub fndvalinrng()
    Dim rsltrng, srchrng As Range
    Dim srch As Integer
    srch = ThisWorkbook.Worksheets("Sheet1").Cells(2, 1).Value
    Set rsltrng = ThisWorkbook.Worksheets("Sheet1").Range("F4:F19")
    Set srchrng = Application.WorksheetFunction.Search(srchrng, srch)
    
    ThisWorkbook.Worksheets("Sheet1").Cells(2, 2).Value = _
    Application.WorksheetFunction.Lookup(2 ^ 15, srchrng, rsltrng)
    
    End Sub
    Im converting to VBA code because i have a huge dataset.

    Please help me out


    Regards,
    Ramanan
    Last edited by Excel Fox; 04-30-2013 at 12:29 PM. Reason: Code Tags Added

Similar Threads

  1. Lookup Picture Using Formula Without Using VBA
    By paul_pearson in forum Excel Help
    Replies: 16
    Last Post: 11-06-2013, 01:28 PM
  2. Lookup Picture Using Formula Without Using VBA
    By mahmoud-lee in forum Excel Help
    Replies: 3
    Last Post: 06-13-2013, 06:53 PM
  3. Create A Dynamic Border Using Excel Native Formula
    By mahmoud-lee in forum Excel Help
    Replies: 4
    Last Post: 06-02-2013, 06:07 AM
  4. Nested Search Function Excel Formula
    By trankim in forum Excel Help
    Replies: 6
    Last Post: 10-29-2012, 10:29 PM
  5. Replies: 3
    Last Post: 04-08-2012, 09:44 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •