+ Reply to Thread
Results 1 to 3 of 3

Dynamic cell refferemce in a VBA formula

  1. #1
    Registered User
    Join Date
    08-09-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2012
    Posts
    4

    Dynamic cell refferemce in a VBA formula

    Hi,

    At the top I enter the value of a cell B1: "Product List".
    Then I am populating the spreadsheet with a number of rows that is always variable.
    Then at the bottom I need to enter a formula that needs to output the following result: "End of Product List" where "Product List" is the dynamic reference to B1.
    If the user then erases any number of rows in the spreadsheet, the bottom still reads the same.
    If the user changes the value of B1 then I need the bottom to be able to update the change so a dynamic link to the cell B1 is necessary.

    then of course, after I figure this out, I need to populate adjacent the bottom cell in a similar way with a dynamic sum.

    Any help ? I tried Formula, FormulaR1C1 but all seem to be stuck on hard coded references E.g.
    Range("B40").FormulaR1C1 = "=""End of "" & R[-39]C"
    In simple words, how could I replace the [-39] with a variable I set programmatically

    Thanks !

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Dynamic cell refferemce in a VBA formula

    Why not hardcode B1?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-09-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2012
    Posts
    4

    Re: Dynamic cell refferemce in a VBA formula

    Thanks Norie ! You made my day !
    Here is how I solved it based on your suggestion

    MyRange = "B1"
    Range("B40").Formula = "=""End of "" & " & MyRange


    I can control programmatically the locations of the cell B1 and B40. I tried to work with the double quotation marks but for some reason it did not work for me until you showed me how ... lol !

+ 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. [SOLVED] Using Dynamic cell reference in cell formula created by VBA
    By grazian2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2013, 11:05 AM
  2. How to use VBA to enter a formula into a cell where the formula contains a dynamic array
    By LadyFenelopy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2012, 09:46 AM
  3. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  4. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  5. Replies: 0
    Last Post: 02-28-2006, 09:10 PM

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