+ Reply to Thread
Results 1 to 6 of 6

VBA replace part of formula IF and VLOOKUP

  1. #1
    Registered User
    Join Date
    10-12-2016
    Location
    Nederland
    MS-Off Ver
    2013
    Posts
    3

    VBA replace part of formula IF and VLOOKUP

    Hi,

    I try to solve a VBA problem. I like to have a dropdown list with the choices of January to December in the worksheet "Net Sales-Budg-FC-PY". This worksheet links to 3 different worksheets with numbers of each month (jan-dec) in a different column (5-16). Each worksheet has the same column number from jan-dec.

    I like with VBA to change the formula on each cell Range("E5:S238") when I choice a different month.
    The difficulty is that the formula "Find and Replace" don't replace a part of a formula or the column number of the formula between semicolon ";". My formula look like this each cell Range("E5:S238"):

    - cell E5
    Please Login or Register  to view this content.
    - cell E6
    Please Login or Register  to view this content.
    and so on...

    And
    - cell F5
    Please Login or Register  to view this content.
    - cell F6
    Please Login or Register  to view this content.
    and so on...

    Dropdown list:
    To choose February: January with the column ;5; have to be changed in February with column ;6;
    To choose March: February with the column ;6; have to be changed in March with column ;7;
    and so on...

    Can somebody help me with the wright formula? Thanks in advance!
    Last edited by Made; 10-12-2016 at 08:25 AM.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA replace part of formula IF and VLOOKUP

    Change the number in your formula, to a reference to a named range, which is changed to the relevant month number by changing the dropdown list.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

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

    Re: VBA replace part of formula IF and VLOOKUP

    If your dropdown list is in cell A1, then put a formula like this (in cell B1 for this example) to convert the month name to a month number 5-16
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then change your formulas to reference the cell with the month number...
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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.

  4. #4
    Registered User
    Join Date
    10-12-2016
    Location
    Nederland
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA replace part of formula IF and VLOOKUP

    Thank you Olly for you reply . I've got a conflict with the named range. It can't find the value. I tried AlphaFrog's solution and it works without VBA.

  5. #5
    Registered User
    Join Date
    10-12-2016
    Location
    Nederland
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA replace part of formula IF and VLOOKUP

    Thanks AlphaFrog! It works without using VBA. So simple and effective.

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

    Re: VBA replace part of formula IF and VLOOKUP

    Quote Originally Posted by Made View Post
    Thanks AlphaFrog! It works without using VBA. So simple and effective.
    You're welcome. Thanks for the feedback.

+ 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. Find & Replace Part of a Formula
    By kalebsmith10 in forum Excel General
    Replies: 2
    Last Post: 03-02-2016, 08:55 PM
  2. How to replace part of a formula with VBA
    By rockfrawg in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2014, 05:23 PM
  3. Find and Replace part of formula using VBA
    By chococ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2014, 01:26 PM
  4. Replace part of formula VBA
    By Testnntest in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2013, 04:20 AM
  5. find and replace part of formula only
    By iceshimmer in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-06-2013, 06:51 AM
  6. How do I replace part of a formula using VBA?
    By Vaslo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2012, 12:46 PM
  7. [SOLVED] Q: DDE Link - Replace Part of the Formula
    By Reto Walker in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-14-2006, 12:15 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