Consulting

Results 1 to 4 of 4

Thread: How to insert a Reference in a sheet

  1. #1
    VBAX Regular
    Joined
    Aug 2004
    Posts
    11
    Location

    How to insert a Reference in a sheet

    This is gonna show my ignorance, but I'm banging my head...
    I'm populating a worksheet ("Scorecard")with data from another worksheet, but I'd like it to create a Reference to the data instead of the value.

    I thought I was on the right track with the lines below,

    wSheetstr = "='" & wSheet.Name & "'!" 
    Worksheets("Scorecard").Cells(ScorecardRow, 1).Formula = wSheetstr & "A8"
    This works, but the problem is that (in another line), I'd like to use variables (R1C1 format) to locate where the Referenced cell is located.

    In other words, the following line populates the scorecard with the correct data...

    Worksheets("Scorecard").Cells(ScorecardRow, 3) = _
    wSheet.Cells(Ycounter + 2, Xcounter + 5)
    .... But Id like it to populate it with a Reference to the data instead.
    (& preferably have the Reference in A1 format, but as long as works I dont care)
    Any ideas? - I'll bet it's so simple.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    When you build the range string you can use A1 or R1C1 references.

    Variable Row y A1 Style
    wSheetstr = "='" & wSheet.Name & "'!" 
    Worksheets("Scorecard").Cells(ScorecardRow, 1).Formula = _
    wSheetstr & "A" & y
    Variable Row y and Column x A1 Style
    wSheetstr = "='" & wSheet.Name & "'!" 
     Worksheets("Scorecard").Cells(ScorecardRow, 1).Formula = _
    wSheetstr & Cells(y,x).Address
    Variable Row y and Column x R1C1 Style
    wSheetstr = "='" & wSheet.Name & "'!" 
      Worksheets("Scorecard").Cells(ScorecardRow, 1).Formula = _
    wSheetstr & "R" & y & "C" & x

  3. #3
    VBAX Regular
    Joined
    Aug 2004
    Posts
    11
    Location

    solved

    Cells(y,x).Address
    - ahhh

    Thank you DRJ, you ARE the Jedi Master.

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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