+ Reply to Thread
Results 1 to 3 of 3

Create an INDEX formula in VBA where one cell is based on ActiveCell

  1. #1
    Registered User
    Join Date
    11-07-2016
    Location
    Indianapolis, Indiana
    MS-Off Ver
    2010
    Posts
    36

    Create an INDEX formula in VBA where one cell is based on ActiveCell

    I have this formula created in excel vba:

    PHP Code: 
     Selection.FormulaArray _
                     
    "=INDEX(Data!R1C8:R1000000C8,SMALL(IF(R2C2=Data!R[-4]C3:R1000000C3,ROW(Data!R[-4]C3:R1000000C3)-MIN(ROW(Data!R1C3:R1000000C3))+1,""""),ROW(Data!R[-4]C3)))" 
    What I am trying to do (I dont' know if it is possible) is have R2C2 [SMALL(IF(R2C2) ....] be based on an activecell. Specifically, ActiveCell.Offset(-1, -3).
    Is this possible?

    I am trying to do this because this formula is in a loop and I need it to stay the same within the loop but change every time the loop re-loops.
    Here is the part of the loop I am working on:


    PHP Code: 
         Selection.FormulaArray _
                     
    "=INDEX(Data!R1C8:R1000000C8,SMALL(IF(R2C2=Data!R[-4]C3:R1000000C3,ROW(Data!R[-4]C3:R1000000C3)-MIN(ROW(Data!R1C3:R1000000C3))+1,""""),ROW(Data!R[-4]C3)))"
                
    Dim x As Long
                x 
    ActiveSheet.UsedRange.Rows.Count
                ActiveCell
    .Copy Range(Cells(6ActiveCell.Column), Cells(xActiveCell.Column))


                 
    ActiveCell.Select
            ActiveCell
    .Offset(01).Activate
                Selection
    .FormulaArray _
                      
    "=INDEX(Data!R1C9:R1000000C9,SMALL(IF(R2C2=Data!R[-4]C3:R1000000C3,ROW(Data!R[-4]C3:R1000000C3)-MIN(ROW(Data!R1C3:R1000000C3))+1,""""),ROW(Data!R[-4]C3)))"
                
    ActiveSheet.UsedRange.Rows.Count
                 ActiveCell
    .Copy Range(Cells(6ActiveCell.Column), Cells(xActiveCell.Column))

                 
    ActiveCell.Select
             ActiveCell
    .Offset(01).Activate
                 Selection
    .FormulaArray _
                     
    "=INDEX(Data!R1C10:R1000000C10,SMALL(IF(R2C2=Data!R[-4]C3:R1000000C3,ROW(Data!R[-4]C3:R1000000C3)-MIN(ROW(Data!R1C3:R1000000C3))+1,""""),ROW(Data!R[-4]C3)))"
                 
    ActiveSheet.UsedRange.Rows.Count
                 ActiveCell
    .Copy Range(Cells(6ActiveCell.Column), Cells(xActiveCell.Column))
                
             
    ActiveCell.Offset(rowOffset:=-3columnOffset:=4).Activate 
    Any advice?

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Create an INDEX formula in VBA where one cell is based on ActiveCell

    Quote Originally Posted by KAP123 View Post

    What I am trying to do (I dont' know if it is possible) is have R2C2 [SMALL(IF(R2C2) ....] be based on an activecell. Specifically, ActiveCell.Offset(-1, -3).
    ActiveCell.Offset(-1, -3) is this R[-1]C[-3] in R1C1 address reference notation

    SMALL(IF(R[-1]C[-3])


    Releative.png
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-07-2016
    Location
    Indianapolis, Indiana
    MS-Off Ver
    2010
    Posts
    36

    Re: Create an INDEX formula in VBA where one cell is based on ActiveCell

    Thank you!

+ 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. [SOLVED] select entire column based on activecell - multiply cells based if found empty cell
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-08-2016, 01:52 AM
  2. Loop Autofill (based on activecell, not cell reference, varying row counts)
    By xtinct2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2015, 12:29 PM
  3. Create a Formula from Set Variables as ActiveCell
    By lreyes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2015, 09:28 PM
  4. [SOLVED] Using INDEX to create cell references nested in a SLOPE formula
    By Bioc in forum Excel General
    Replies: 4
    Last Post: 02-05-2015, 08:20 AM
  5. Replies: 6
    Last Post: 09-09-2014, 02:25 PM
  6. Automaticaly Create WebQueries based on worksheet index and URL string in cell
    By pmarzagao in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-10-2014, 08:03 AM
  7. CREATE NEW WORKBOOKS BASED ON ACTIVECELL & BUTTON CLICK
    By Eddy Stan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2006, 01:35 AM

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