+ Reply to Thread
Results 1 to 16 of 16

Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with VBA

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with VBA

    Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with VBA

    Dear Forum,

    As I am at work cannot upload a file due to the strict policy however what I require is to Convert My Range of Specific Cells into Values however I need to only make specific cells which have no fill color (only these cells which have a formula into values ) as the Entire Range would have two different sets of formulas
    Ex - Formula 1 = "=SUMIFS('DATA (New)'!$N:$N,'DATA (New)'!$R:$R,INDIRECT(ADDRESS(7,COLUMN(),2)),'DATA (New)'!$D:$D,CHOOSE(MATCH(INDIRECT(ADDRESS(4,COLUMN(),2)),{""HSPL"",""BANK"",""TPDSA"",""CCST"",""DIGI"",""DIRECT""},0),""HLSIL"",""HDFC BANK LTD"",""TPDSA"",""CCST"",""DIGI"",""WALKIN""),'DATA (New)'!$E:$E,INDIRECT(ADDRESS(ROW(),3,3)))"

    Formula - 2 = SUM(A2:A5) as these are Sub-Total Cells of the above rows 2,3,4 & 5 LIKEWISE...

    Please Login or Register  to view this content.
    This code works only when the Data Is Filtered , i need this to work even when the Data is not Filtered so how do I achieve the same result...

    Regards
    e4excel

  2. #2
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Dear Forum,

    Can something be tweaked to only work only on the cells in that Range where the Fill Color is No Fill as the In between Sub-Total Cells have a different Fill Color..

    Regards
    e4excel

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    You can't just make up things to pass to SpecialCells.

    Do the cells initially contain a formula, or are they blank? Either of those options will work with specialcells, then you would have to loop through and check the fill colour as you go. Alternatively, you could actually apply a filter and loop through the visible cells.
    Rory

  4. #4
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    These cells have formula and the cells filled with color also contain a different formula, I just need the formula to work on the cells which are NO FILL and without applying the filter..

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    If they originally have formulas then you can loop through them using

    Please Login or Register  to view this content.
    but you will need to check the fill for each one before processing it - eg test if the cell's Interior.Colorindex property equals xlcolorindexnone

  6. #6
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Dear Rorya,

    In that Range from ROw 8 till 55 there are 2 different sets of formulas - one is SUMIF from ROW 8 till 12 then in the cell wih ROW 13 will contain the Summation of the cells from 8 till 12, so I just need to convert the cells with the SUMIFS formula into value and the cells which act as SUB-TOTALs to be kept as it is (i.e. they should have formulas )..

  7. #7
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Quote Originally Posted by rorya View Post
    If they originally have formulas then you can loop through them using

    Please Login or Register  to view this content.
    but you will need to check the fill for each one before processing it - eg test if the cell's Interior.Colorindex property equals xlcolorindexnone
    The above code changes all the formulas into values and does not distinguish between the Fill Color.

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Are you saying that the SUM formula cells also have no fill colour?

  9. #9
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    No the SUM formula has Dark Grey Color as that is the ROW which acts as SUBTOTAL Row and the SUMIFS in between need to be converted into values so my code is working fine however I have to always filter the data in order to use it, i need something which can differentiate without filetering the data...

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Then I suggest you look at what I posted in post 5. Although if all of the cells in that range are formulas, there is no point to specialcells - just loop through all the cells.

  11. #11
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Quote Originally Posted by rorya View Post
    Then I suggest you look at what I posted in post 5. Although if all of the cells in that range are formulas, there is no point to specialcells - just loop through all the cells.
    Please Login or Register  to view this content.
    This does not differentiate between the 2 Sets of Formulas...so how do I make it work only on the cells which are not filled with any color.

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    As I said before:

    but you will need to check the fill for each one before processing it - eg test if the cell's Interior.Colorindex property equals xlcolorindexnone

  13. #13
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Quote Originally Posted by rorya View Post
    As I said before:
    Ok I got it now, this worked..

    Please Login or Register  to view this content.

  14. #14
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    You commented out the wrong line. Your version is - purely by coincidence since xlfilternofill happens to have the same value as xlcelltypevisible - looping through all the visible cells in the range

  15. #15
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Quote Originally Posted by rorya View Post
    You commented out the wrong line. Your version is - purely by coincidence since xlfilternofill happens to have the same value as xlcelltypevisible - looping through all the visible cells in the range
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Converting formulas in a Range of CELLS which are in between SUB-TOTALs to Values with

    Dear Rorya,

    Plesae advise...

+ 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] Copy range of cells and paste most as values and some as formulas
    By Absalon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2021, 03:55 PM
  2. Replies: 3
    Last Post: 07-22-2019, 08:35 AM
  3. DAX Formulas (worng grand totals and missing values)
    By Paragin in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-04-2018, 08:55 PM
  4. Copy only cells that contain values from a range cells that contain formulas to next row
    By gjwilson1216 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2015, 11:12 AM
  5. Converting Specific Formulas into Values
    By pareshvm in forum Excel General
    Replies: 1
    Last Post: 10-17-2012, 09:31 AM
  6. Out of memory-Converting Formulas to Values
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-03-2012, 02:13 PM
  7. Converting a range of cells to their values
    By echo_oscar in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-22-2012, 10:38 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