+ Reply to Thread
Results 1 to 5 of 5

Using Dynamic cell reference in cell formula created by VBA

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Using Dynamic cell reference in cell formula created by VBA

    Hello!

    Currently, I am attempting to write VBA code that will open a user selected file. In the file, I need 3 things calculated to be imported into the original sheet:
    1) Sum of the Qty column when column State="CA""
    2) Sum of the Qty column when column State="TX"
    3) Sum of the Qty column when column Member= "Walgreens"

    Unfortunately, The Qty, State, and Member columns do not stay in the same location each week. I have code that finds their column locations

    Please Login or Register  to view this content.
    I am having trouble writing cell formulas that can utilize those cell locations

    If someone could help me out in writing formulas that will work with the variables above, or if anyone knows of a better method, that would be fantastic.

    Thank you for your time,

    Grazian2

    Some Ideas that failed:
    Please Login or Register  to view this content.

    All Code:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,593

    Re: Using Dynamic cell reference in cell formula created by VBA

    Some different approaches:

    Please Login or Register  to view this content.


    Regards, TMS


    Edit: Test Data

    HTML Code: 
    Last edited by TMS; 07-24-2013 at 05:23 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Using Dynamic cell reference in cell formula created by VBA

    Please Login or Register  to view this content.
    Last edited by snb; 07-24-2013 at 05:23 PM.



  4. #4
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Using Dynamic cell reference in cell formula created by VBA

    Thank you for the replies!!

    TMshucks, the second to last formula declaration worked great! Thank you for your help.

    Please Login or Register  to view this content.

    SNB, thank you for your reply as well!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,593

    Re: Using Dynamic cell reference in cell formula created by VBA

    You're welcome. Thanks for the rep.


    I like that approach as you can always comment out the ".Value = .Value" to see if the formula is what you were expecting. But, horses for courses


    Regards, TMS

+ 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. check formula integrity: replace dynamic cell reference with fixed value?
    By orchidee in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-07-2013, 06:18 PM
  2. Use Match or Lookup to create dynamic cell reference in VBA R1C1 formula
    By rmunsun1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-20-2012, 06:10 AM
  3. Dynamic Formula Ranges with reference to values in another cell
    By dunda1985 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2011, 05:08 AM
  4. Replies: 0
    Last Post: 06-16-2011, 09:46 AM
  5. Dynamic Cell Reference in VBA Formula
    By mworonuk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2009, 01:41 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