+ Reply to Thread
Results 1 to 7 of 7

VBA code: Change cell reference in cell formulas based on a single cell or drop down menu?

  1. #1
    Registered User
    Join Date
    09-13-2017
    Location
    United States
    MS-Off Ver
    MS Office 365
    Posts
    43

    VBA code: Change cell reference in cell formulas based on a single cell or drop down menu?

    Hi Everyone,

    I was wondering if it is possible to have a vba code that can change a cell reference either based on a single cell value or a drop down menu?

    For Example:
    In a workbook, I have 8 worksheets. First 7 are MON, TUE, WED, THU, FRI, SAT, and, SUN. The eighth worksheet, a range of cells contain formulas that reference to MON. I want to change MON to the other worksheets and change from that worksheet to another worksheet, and so on.

    Is this possible? Please let me know, I have been google search couldn't find anything. I also apologize for not having a workable workbook.

    Thank you!

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: VBA code: Change cell reference in cell formulas based on a single cell or drop down m

    Yes, and you don't need VBA for that..

    You can use the Indirect function.

    Attach you sample workbook and I will help you out..
    Cheers!
    Deep Dave

  3. #3
    Registered User
    Join Date
    09-13-2017
    Location
    United States
    MS-Off Ver
    MS Office 365
    Posts
    43

    Re: VBA code: Change cell reference in cell formulas based on a single cell or drop down m

    Thank you NeedforExcel!

    Attached are the excel files. In master.xlsx, A1:A20 are the formula I want to change from MON to other worksheets.

    Thank you
    Attached Files Attached Files

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: VBA code: Change cell reference in cell formulas based on a single cell or drop down m

    Hi,

    Please see the file attached
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA code: Change cell reference in cell formulas based on a single cell or drop down m

    To add to NeedForExcel's excellent answer, here's a good guide for the Indirect function.

    INDIRECT Function
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  6. #6
    Registered User
    Join Date
    09-13-2017
    Location
    United States
    MS-Off Ver
    MS Office 365
    Posts
    43

    Re: VBA code: Change cell reference in cell formulas based on a single cell or drop down m

    Thanks for your solution but I applied this to my original workbook and I notice that my workbook won't update unless I have the other workbook opened. Is it still possible to use indirect while being able to have the other workbook closed and still update?

    Thank you

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: VBA code: Change cell reference in cell formulas based on a single cell or drop down m

    Well, as far as I am aware, Indirect does wont work if your 2nd workbook is closed.

+ 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. Change reference cell in formula based on selection in drop down list
    By devin.fentie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-13-2016, 03:40 AM
  2. Replies: 1
    Last Post: 08-05-2015, 01:13 AM
  3. Change value of cell based on a drop down menu option.
    By laxtui in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-10-2013, 07:23 AM
  4. Replies: 1
    Last Post: 12-09-2013, 04:19 PM
  5. Hide Rows based on the value of a drop down menu in a single cell.
    By sayoban in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-25-2013, 04:36 PM
  6. [SOLVED] Pivot Table cell/range to change based on drop down menu
    By PippiLaRue in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 09:36 AM
  7. [SOLVED] Drop down menu-How do you produce a drop down menu in a single cell in Excel
    By Freddo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-04-2006, 04:35 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