+ Reply to Thread
Results 1 to 3 of 3

Relative Reference

  1. #1
    Registered User
    Join Date
    03-21-2006
    Posts
    14

    Relative Reference

    I've recorded the following macro:

    Sub 2()
    '
    ' 2 Macro
    ' Macro recorded
    '
    ' Keyboard Shortcut:
    '
    Dim i As Integer
    i = 4
    Do
    ActiveCell.Formula = "=Q6/(HLOOKUP($R$2, $C$3:$O$40, (" & i & ")))"
    ActiveCell.Offset(1, 0).Select
    i = i + 1
    Loop Until IsEmpty(ActiveCell.Offset(1, 0))
    '
    End Sub

    My problem is I need the Q6 in the formula to correspond w/ whatever row it is in. So in row 7 it should be Q7 and in row 8 it should be Q8 and so on. I believe this is called relative reference...but I can't figure out how to make it work. Can anybody help?

    Thanks in advance!!

  2. #2
    Tom Ogilvy
    Guest

    RE: Relative Reference

    Sub 2()
    '
    ' 2 Macro
    ' Macro recorded
    '
    ' Keyboard Shortcut:
    '
    Dim i As Integer
    i = 4
    Do
    ActiveCell.Formula = "=Q" & activecell.row & _
    "/(HLOOKUP($R$2, $C$3:$O$40, (" & i & ")))"
    ActiveCell.Offset(1, 0).Select
    i = i + 1
    Loop Until IsEmpty(ActiveCell.Offset(1, 0))
    '
    End Sub

    --
    Regards,
    Tom Ogilvy


    "liseladele" wrote:

    >
    > I've recorded the following macro:
    >
    > Sub 2()
    > '
    > ' 2 Macro
    > ' Macro recorded
    > '
    > ' Keyboard Shortcut:
    > '
    > Dim i As Integer
    > i = 4
    > Do
    > ActiveCell.Formula = "=Q6/(HLOOKUP($R$2, $C$3:$O$40, (" & i &
    > ")))"
    > ActiveCell.Offset(1, 0).Select
    > i = i + 1
    > Loop Until IsEmpty(ActiveCell.Offset(1, 0))
    > '
    > End Sub
    >
    > My problem is I need the Q6 in the formula to correspond w/ whatever
    > row it is in. So in row 7 it should be Q7 and in row 8 it should be Q8
    > and so on. I believe this is called relative reference...but I can't
    > figure out how to make it work. Can anybody help?
    >
    > Thanks in advance!!
    >
    >
    > --
    > liseladele
    > ------------------------------------------------------------------------
    > liseladele's Profile: http://www.excelforum.com/member.php...o&userid=32688
    > View this thread: http://www.excelforum.com/showthread...hreadid=537319
    >
    >


  3. #3
    Registered User
    Join Date
    03-21-2006
    Posts
    14

    Smile

    Thank you so much!!

+ 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