+ Reply to Thread
Results 1 to 4 of 4

Periodically adding additional text to current formula

  1. #1
    Registered User
    Join Date
    06-06-2017
    Location
    Edinburgh
    MS-Off Ver
    2013
    Posts
    2

    Exclamation Periodically adding additional text to current formula

    Hi,

    I am currently running a vlookup indirect / match formula which retrieves information from several external worksheets, but I don't know how to automatically update the formula to account for any new external worksheets?

    Ideally, I need to write a macro which can add additional lines of text to the current formula to automatically account for the new external worksheets, rather than having to update the formula manually.

    Could someone please help me with this? My Excel skills are basic and I don't know where to start. Any help would be very much appreciated!

    Thanks

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Please help - periodically adding additional text to current formula

    Welcome to the forum

    Please post your formula

    What is its cell reference?
    Is it then copied down from there to the last row in that column?
    Last edited by kev_; 06-06-2017 at 12:59 PM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    06-06-2017
    Location
    Edinburgh
    MS-Off Ver
    2013
    Posts
    2

    Re: Please help - periodically adding additional text to current formula

    Thanks for replying so quickly!

    The formula is as below:

    =IF(AND($N$19=$L$37,$K$18=$J$35),VLOOKUP($N$19,INDIRECT("'["&$P$35&"]"&$L$43&"'!"&$L$45),MATCH($M20,INDIRECT("'["&$P$35&"]"&$L$43&"'!"&$L$46),0),FALSE)....

    The formula manually repeats itself numerous times, but only the references to cells J and P change, so the next instance would be the same but with reference to J36 and P36 and so on.

    However, There is a significant number of rows below this and I don't have the capacity to update the formula manually, so I am looking for a formula / macro to automatically add the next cell down ie. J37 and P37 without removing and of the current formula as I will still need access to historical data.

    Is there a possible way to do this?

    Thanks very much

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Periodically adding additional text to current formula

    Late EDIT
    just spotted that I forgot to alter the text I pasted in these 2 lines
    Please Login or Register  to view this content.
    Should of course be cell containing:
    "$L$45" (VlookUp range)
    "$L$46"(Match range)
    The macro works fine - just the message text is wrong
    --------------------------------------

    see attached workbook
    Run the macro with {CTRL} t

    Running the macro
    The macro asks the user for 4 new references and replaces the following cell references with ones appropriate to the additional workbook:
    "$P$35" (Workbook name)
    "$L$43" (SheetName)
    "$L$45" (VlookUp range)
    "$L$46"(Match range)
    - when inputting you must include the $ signs (it is searching and replacing the string)
    - upper or lower case is fine (I have wrapped the input boxes in UCase but it was not strictly necessary - Excel would have changed them itself)

    Results appear A1 to B2
    Cell B1 has been named "ModelAddOn" - this already contains the segment formula
    Cell B2 has been named "NewAddOn" - this will contain the amended segment
    Cells A1 and A2 will contain the formula text so that you can compare the 2 strings

    Please Login or Register  to view this content.
    Completing the job

    You only provided a segment of the formula, telling me that you are confident in finishing this off.
    To generate a formula that VBA and Excel would treat as such, I added a ")" at the back end of the segment
    2 variables have been declared in anticipation: oldFormula & newFormula

    If what I have done is correct you will need to concatenate the latest formula with the segment (probably removing my extra bracket and adding it at the back end of the total string)
    If you need further help let me know.

    To build up the string it was much easier to put it originally in Excel, drag it into VBA and then manipulate it - you should do the same with the latest formula
    Attached Files Attached Files
    Last edited by kev_; 06-09-2017 at 09:43 AM.

+ 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] Adding an additional Condition to a working Formula
    By hammer2 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-29-2016, 06:58 AM
  2. adding relative text to additional cells
    By roklock in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-09-2013, 02:51 PM
  3. Adding a check-box without additional text
    By MavGunloc in forum Excel General
    Replies: 2
    Last Post: 04-01-2013, 04:29 PM
  4. [SOLVED] Attempting to update current formula with additional required criteria
    By Webbers in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-27-2012, 10:17 AM
  5. Adding additional string to formula
    By rhudgins in forum Excel General
    Replies: 2
    Last Post: 06-23-2011, 03:38 PM
  6. [SOLVED] Adding additional rows with formula
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2006, 08:40 AM

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