+ Reply to Thread
Results 1 to 7 of 7

VBA insert formula referencing offset cells and anchor reference

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    VBA insert formula referencing offset cells and anchor reference

    Hi all,

    I have a formula I am trying to insert into a range of cells below the active cell that references the left most column from the same row and the active cell. The complication comes when I try and add an anchor to that cell to apply it to a range.

    An example might be, user selects active cell H3 and runs macro. Row A contains data from cell A4 to A50. In cells H4:H50 the formula that needs to be entered is
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please note, the column and row number of the active cell may be different but the user will always reference column A of the same row.

    I've come up with the below piece of code that works to put the formula in the correct cell directly below the active cell but without the anchor "$" against the column and row respectively.

    Please Login or Register  to view this content.

    Any help would be most appreciated, thanks in advance!

    James
    Last edited by JPalms; 07-19-2013 at 09:30 AM.

  2. #2
    Registered User
    Join Date
    10-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: VBA insert formula referencing offset cells and anchor reference

    Solved it myself with a workaround! Thanks anyway...

    I would still like to know how to add anchored references via VBA but the below works in this instance:

    Please Login or Register  to view this content.

    James

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA insert formula referencing offset cells and anchor reference

    perhaps simply
    Please Login or Register  to view this content.
    Last edited by JosephP; 07-19-2013 at 09:58 AM. Reason: add missing )
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    10-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: VBA insert formula referencing offset cells and anchor reference

    Thank you Joseph. I'm normally one to overcomplicate but that simplified code needs some work with the quotation marks and brackets I believe...

    I get an "Expected list separator error"...

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA insert formula referencing offset cells and anchor reference

    no but it was missing a closing parenthesis which I have now added

  6. #6
    Registered User
    Join Date
    10-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: VBA insert formula referencing offset cells and anchor reference

    Thanks Joseph. Change to reference the cell below the active cell and to fill right the way down but now works like a charm.

    Please Login or Register  to view this content.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA insert formula referencing offset cells and anchor reference

    you're welcome :-)

    please don't forget to mark the thread solved (click the 'thread tools' link at the top, then 'mark solved')

+ 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. Reformatting - insert formula with offset, then offset to next cell
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2011, 05:41 AM
  2. Cell as reference anchor to another sheet
    By michael.g in forum Excel General
    Replies: 17
    Last Post: 10-29-2009, 04:29 PM
  3. Anchor Reference in a Formula
    By rolito in forum Excel General
    Replies: 4
    Last Post: 06-07-2007, 04:03 AM
  4. [SOLVED] Reference 5 cells offset from another for copying.
    By justagrunt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2006, 06:00 PM
  5. How do I anchor a cell reference?
    By CasaJay in forum Excel General
    Replies: 3
    Last Post: 06-07-2006, 02:15 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