+ Reply to Thread
Results 1 to 13 of 13

Replacing part of formula in cells

  1. #1
    Registered User
    Join Date
    02-15-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    10

    Replacing part of formula in cells

    Hi Everyone

    is there any good way to replace the "H13", "H17", "H21", "H25" and "H29" link in my formula on top with the FORMULA in these cells?

    I've attached an image file to make it easy to understand my problem.
    aaaa.jpg

    For example:

    I want to replace the H13 in the following formula "=SE($A5="TACO";H13" with the formula in "H13" cell (=index('[TACO.xlsx]CMVCol taco3'!D$5:D$687;match...)

    SE function = IF function, I'm from Brazil and my MS Office 2016 is in portuguese.

    What shoul I do, people? Do I have to use Macro and VBA? is there any unknown (for me) option for this job? any other way?

    I have to repeat the process with many columns, I don't want to copy and paste formulas replacing the links, it wil take too many hours, time that I don't have.

    Please, help me with it

    Cheers;
    Tony

  2. #2
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Replacing part of formula in cells

    Try this Tony

    Please Login or Register  to view this content.
    HTH,
    Maud

  3. #3
    Registered User
    Join Date
    02-15-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    10

    Re: Replacing part of formula in cells

    Thank you so much indeed, Maud, but now, please, in your code, Excel recreate the formula for the "H" column. How can I repeat the process with the "I", "J", "K"... column and so on?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Replacing part of formula in cells

    Untested, see if this works...
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-15-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    10

    Re: Replacing part of formula in cells

    Thanks for your attention, jindon , but no, the scrip is not working.

    okay, I'm sharing here a link to download an example file what I want

    http://s000.tinyupload.com/?file_id=...19153819631273

    In think it might help you to understand my problem.

    Thanks in advance

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Replacing part of formula in cells

    In that particular case, the below is working here.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-15-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    10

    Re: Replacing part of formula in cells

    Awesome, however i'm not a expert at VBA, where is the part of your script that copies the content of B2, B3 and B4 cells? I'd like to be able to change it

    Thanks,
    Tony

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Replacing part of formula in cells

    Please Login or Register  to view this content.
    The bold part is the formula in the cell without "=" sign at the beginning.

  9. #9
    Registered User
    Join Date
    02-15-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    10

    Re: Replacing part of formula in cells

    =SE($A5="TACO";G13;
    SE($A5="IBGE";G17;
    SE($A5="USDA";G21;
    SE($A5="Rotulo";G25;
    G29))))

    How would be your script to replace G13, G17, G21, G25 and G29 with the formula in the cells?

    G13 formula is "=ÍNDICE('[TACO.xlsx]CMVCol taco3'!D$5:D$687;CORRESP($B5;'[TACO.xlsx]CMVCol taco3'!$A$5:$A$687;0);1)*$E5/$C5"

    G17 formula is "=ÍNDICE('[IBGE.xlsx]Tabela de Composição '!G$5:G$1975;CORRESP($B5;'[IBGE.xlsx]Tabela de Composição '!$A$5:$A$1975;0);1)*$E5/$C5"

    G21 formula is "=ÍNDICE([USDA.xlsx]ABBREV!D$2:D$8791;CORRESP($B5;[USDA.xlsx]ABBREV!$A$2:$A$8791;0);1)*$E5/$C5"

    G25 formula is "=ÍNDICE('[Rotulo.xlsx]CMVCol taco3'!D$5:D$687;CORRESP($B5;'[Rotulo.xlsx]CMVCol taco3'!$A$5:$A$687;0);1)*$E5/$C5"

    G29 formula is "=ÍNDICE('[Personalizado.xlsx]CMVCol taco3'!D$5:D$687;CORRESP($B5;'[Personalizado.xlsx]CMVCol taco3'!$A$5:$A$687;0);1)*$E5/$C5"

  10. #10
    Registered User
    Join Date
    02-15-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    10

    Re: Replacing part of formula in cells

    The part "For Each r In Range("b5:h5")" of your code I understood ^^

  11. #11
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Replacing part of formula in cells

    Tony,

    If Jindon's code doesn't work for you and you need me to amend my code to loop through additional columns, please send me a PIM.

    Maud

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Replacing part of formula in cells

    Purely as an alternative, this code assumes that your range references are to cells on the same sheet as the formula cell and that the addresses are relative, not absolute
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  13. #13
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Replacing part of formula in cells

    Hi Tony,

    If this does not meet your needs, you will need to post your file in this thread. The revisedcode will cycle though columns H to K and replace the cell reference with the actual formulas in row 30 of each column. You can easily change the start and end columns in the code.

    HTH,
    Maud

    In a standard module:
    Please Login or Register  to view this content.

+ 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. replacing a part of formula with its value
    By paramnayak in forum Excel General
    Replies: 3
    Last Post: 08-09-2014, 10:25 AM
  2. [SOLVED] Replacing the first part of a cell with a different value
    By papasmurfuo9 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-31-2013, 04:04 AM
  3. [SOLVED] Replacing part of formula in many cells with VBA
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-09-2013, 08:10 AM
  4. [SOLVED] Replacing part of a string with a value of cell for each row
    By diamanthian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2013, 04:26 PM
  5. Replacing a part of a number only
    By mikeyt354 in forum Excel General
    Replies: 2
    Last Post: 03-30-2010, 08:47 AM
  6. Replacing Specific part in a cell
    By sjanaswamy in forum Excel General
    Replies: 1
    Last Post: 08-23-2006, 04:26 PM
  7. Replacing part of a cell text
    By oOpsy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-01-2005, 10:54 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