+ Reply to Thread
Results 1 to 4 of 4

[Solved] VBA Vlookup and complex Formula problem

Hybrid View

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2007
    Posts
    2

    Wink [Solved] VBA Vlookup and complex Formula problem

    Hi all,
    Im trying to turn this formula:

    =MID(VLOOKUP(B103;'Extracto Siebel'!$1:$1048576;5;FALSE);SEARCH("113";VLOOKUP(B103;'Extracto Siebel'!$1:$1048576;5;FALSE);1);13)

    Into something i can put in a macro so it goes automatically in a range with a macro.

    My problem is that "B103" is a variable and refers to 3 cells to the left of where the cell is.

    So. i used this:

    Dim rngCell As Range
           For Each rngCell In Range("B" & ActiveCell.Row & ":B" & (ActiveCell.Row + count))
        rngCell.Offset(0, 3) = Application.WorksheetFunction.Mid((Application.WorksheetFunction.VLookup(rngCell.Value, Sheets("Extracto Siebel").Range("1:1048576"), "5", False)), Application.WorksheetFunction.Search("113", Application.WorksheetFunction.VLookup(rngCell.Value, Sheets("Extracto Siebel").Range("1:1048576"), "5", False), 1), 13)
        
        Next
    But It does not work.

    This one works, but fills everything up with a Fixed reference: "$B$103"
    Range("E" & ActiveCell.Row, "E" & (ActiveCell.Row + count)).Formula = "=MID(VLOOKUP(" & ActiveCell.Offset(0, -3).AddressLocal & ",'Extracto Siebel'!$1:$1048576,5,FALSE),SEARCH(""113"",VLOOKUP(" & ActiveCell.Offset(0, -3).AddressLocal & ",'Extracto Siebel'!$1:$1048576,5,FALSE),1),13)"
    Any way to do it??

    Thanks in Advance!!!!
    Last edited by Bansheete; 12-03-2013 at 08:24 AM.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: VBA Vlookup and complex Formula problem

    Hi,
    Try using FormulaR1C1 instead. So you can use relative and/or absolute references.

    Go in the cell where your formula is, then open the VBE editor immediate windows and type : Debug.Print ActiveCell.formulaR1c1
    Use this result in your code :
    Example :

    rngcell.formulaR1C1 = " the formula here... "
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA Vlookup and complex Formula problem

    Try:

    rngcell.FormulaR1C1="=MID(VLOOKUP(RC[-3];'Extracto Siebel'!R1:R1048576;5;FALSE);SEARCH(""113"";VLOOKUP(RC[-3];'Extracto Siebel'!R1:R1048576;5;FALSE);1);13)"
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Registered User
    Join Date
    02-21-2013
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Vlookup and complex Formula problem

    Thanks!! Using R1C1 Worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Complex Vlookup formula
    By superdonk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-16-2013, 11:58 AM
  2. [SOLVED] Complex if/and formula problem
    By dab37843 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-11-2012, 01:21 PM
  3. Complex vlookup formula question
    By dta1984 in forum Excel General
    Replies: 54
    Last Post: 11-18-2011, 12:23 AM
  4. Help with complex formula - H and VLOOKUP
    By supraruss in forum Excel General
    Replies: 8
    Last Post: 07-01-2008, 12:04 PM
  5. Replies: 2
    Last Post: 03-06-2006, 12:40 PM

Tags for this Thread

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