+ Reply to Thread
Results 1 to 12 of 12

VBA to replace cells containing specific text in a large range with an array formula

  1. #1
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    VBA to replace cells containing specific text in a large range with an array formula

    Hi,

    I've got a large specific range of cells (C4:AZ10000) where some contain the text 'Check'.

    Where each cell contains 'Check" I'd like it replaced with an array formula (below):

    =IFERROR(INDEX('Leave'!$G$1:$G$10432,MATCH(1,IF('Leave!$A$1:$A$10432=$A8,IF(AC$1>='Leave!$I$1:$I$10432,IF(AC$1<='Leave'!$I$1:$I$10432,1))),0)),"Check")

    Unfortunately using find and replace doesn't work because of the need to close the formula with SHIFT + CNTRL + ENTER.

    I also can't drag the formula across the range as I need the formula to return 'Check' under the IFERROR conditions if the Index fails.

    I've search but can't find any suitable solutions.

    Any help would be appreciated.

    Thanks

    David

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

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Perhaps
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Thanks very much jindon,

    It almost works.

    Within my formula the row reference is absolute and needs to remain at row 1 which contains a date (AC$1), but the column changes. When I run the code the row moves.

    Any idea how to fix that?

    Thanks

    David

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

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Ok, then try change to your original formula. (missing few ' before !)
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Hi jindon,

    Unfortunately I still can't get the formula to move across the rows and columns.

    I've attached a small sample file, would you mind having a look?

    Thanks

    David
    Attached Files Attached Files

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

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Missed double quotation for ""Check"" in the formula and need to add a bit of trick.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Hi jindon,

    Unfortunately the formula still references only cell $A8 and AC$1 regardless of where it is on the range, where it needs to ref whatever row it's on for A (4-10000) etc and whatever column it's on C-AZ.

    Thanks

    David

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

    Re: VBA to replace cells containing specific text in a large range with an array formula

    OOps, missed this.
    Quote Originally Posted by DaveBre View Post
    but the column changes. When I run the code the row moves.
    When you say "column changes", how do you want it to change?
    Can you show me the example?
    e.g
    If "Check" is found in Col.C then formula =
    If Col.D then formula =

    etc...

  9. #9
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Hi jindon,

    Thanks.

    I've attached a sample file with the formulas located in the relevant cells, these cells were originally sitting as 'Check'

    Does this help?

    The formula need to reference the date in the column in row 1, and the ID in column A.

    Thanks
    Attached Files Attached Files

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

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Yes, that's what I needed to see...
    Does this work as you want?
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA to replace cells containing specific text in a large range with an array formula

    Hi Jindon.

    Thankyou very much, that works perfectly. Thanks for taking the time to help.

    Cheers

    David

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

    Re: VBA to replace cells containing specific text in a large range with an array formula

    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. How to find replace or change specific text color in a range
    By faizzsheikh in forum Excel General
    Replies: 7
    Last Post: 09-08-2016, 01:53 PM
  2. [SOLVED] How to treat specific text as zero in a formula for finding LARGE numbers from cells
    By masud_jahan in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-26-2016, 11:46 AM
  3. Macro which replace large array formula
    By ALEZI in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2014, 02:32 PM
  4. [SOLVED] How to replace a cell value in a large range of cells?
    By herbie226 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 04-13-2014, 02:12 AM
  5. Replies: 3
    Last Post: 03-04-2014, 01:47 PM
  6. [SOLVED] Long array formula with INDEX and MATCH quits working when range is too large
    By UncleKevy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-05-2013, 09:42 PM
  7. Replies: 7
    Last Post: 09-18-2012, 04:17 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