Consulting

Results 1 to 7 of 7

Thread: Solved: Cell Reference

  1. #1
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location

    Solved: Cell Reference

    hi there,

    Glad to see you again!

    A quick question, I want to match a data in reference cell

    in this case, match a cell is F3, F4, F5 and so on.
    Please advice how to do this
    [VBA]Do Until ActiveCell = ""

    ActiveCell(1, 3).Formula = "=INDEX(Area,MATCH(Data!F3,Area1,0),2)"

    ActiveCell.Offset(1, 0).Select

    Loop[/VBA]

    Thanks in advance

  2. #2
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location

    sample workbook

    all,

    please find the attached for your reference.

    your response is highly appreciated it.
    Rgds, Harto

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    See if this helps Harto:
    [vba]Option Explicit
    Sub LoopFormula()
    Range("D3").Select
    ActiveCell.Formula = "=INDEX(Area,MATCH(Data!F3,Area1,0),1)"
    Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp)).FillDown
    Range("E3").Select
    ActiveCell.Formula = "=INDEX(Area,MATCH(Data!F3,Area1,0),2)"
    Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp)).FillDown
    End Sub[/vba]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Steve,
    There is a problem with your FillDown, It copies down C3 as well.

    [VBA]Option Explicit

    Sub LoopFormula()
    Dim LRw As Long
    LRw = Cells(Rows.Count, 1).End(xlUp).Row
    Range("D3").Formula = "=INDEX(Area,MATCH(Data!F3,Area1,0),1)"
    Range("E3").Formula = "=INDEX(Area,MATCH(Data!F3,Area1,0),2)"
    Range("D3:E" & LRw).FillDown
    End Sub[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Malcolm.....
    [VBA]Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp)).FillDown [/VBA]
    Is it because of the -1
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Yes. You're trying a sneaky way to get the bottom row, but it selects both columns
    Maybe
    Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp).offset(,1)).FillDown
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    All,

    That's work fine.
    Many thank for great support.
    best,
    harto

Posting Permissions

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