+ Reply to Thread
Results 1 to 4 of 4

Relative reference in VBA

  1. #1
    Registered User
    Join Date
    03-20-2018
    Location
    Bath, England
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    11

    Relative reference in VBA

    Hello all,

    I am using the following:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("A1:AA999")) Is Nothing Then
    Cells(76, 3).Copy
    End If
    If Target.Cells.Count > 1 Then Exit Sub
    Application.ScreenUpdating = False
    Cells.Interior.ColorIndex = 0
    With Target
    .EntireRow.Interior.ColorIndex = 8
    End With
    Application.ScreenUpdating = True
    End Sub

    I'm looking to be able to use a relative reference to copy the cell in column C with the corresponding row number. So change this part: Cells(76, 3).Copy

    Apologies, quite new to VBA, I'm sure there's a simple answer!

    Thanks.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Relative reference in VBA

    If you want the same row as the target cell, then

    Please Login or Register  to view this content.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    03-20-2018
    Location
    Bath, England
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    11

    Re: Relative reference in VBA

    Perfect, thank you!

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Relative reference in VBA

    ThreadTools @TopOfThread allows you mark thread SOLVED

    Solved.jpg
    Last edited by kev_; 03-20-2018 at 07:21 AM.

+ 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. Relative Reference
    By jassbru in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2012, 11:39 PM
  2. Replies: 5
    Last Post: 09-21-2012, 02:08 PM
  3. change from relative reference to absolute reference
    By ronlau123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-13-2011, 04:57 AM
  4. Relative Reference
    By JDMCMAMC815 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2010, 02:33 PM
  5. Replies: 0
    Last Post: 11-15-2007, 02:35 AM
  6. Tab name, relative reference
    By dhatfield in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-09-2007, 01:11 PM
  7. Relative Reference
    By liseladele in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2006, 03:17 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