Results 1 to 5 of 5

Only apply formula for visible cells isn't working

Threaded View

  1. #1
    Registered User
    Join Date
    02-17-2016
    Location
    Vienna, Austria
    MS-Off Ver
    2013
    Posts
    10

    Question Only apply formula for visible cells isn't working

    Hi guys,

    been trying to fix my problem for the last couple of days but weren't able to do so...
    My worksheet looks like the following:

    ___________|_Product1_|_Product2_|_Product3_|_Product4_|
    Shop1      |    X     |     X    |          |          |
    Shop2      |          |     X    |     X    |          |
    Shop3      |    X     |          |          |     X    |
               |          |          |          |          |
    Ingredient1|          |     X    |          |     X    |
    Ingredient2|    X     |     X    |     X    |     X    |
    Ingredient3|    X     |          |     X    |          |
    I'm using a macro which calls other macros depending on a data validation list selection. The macro looks like the following:
    Sub Shop1()
    Dim LastColumn As Long, x As Long
    LastColumn = ActiveSheet.Cells(3, Columns.Count).End(xlToLeft).Column
    For x = 4 To LastColumn
       If UCase(Cells(7, x).Value) = "X" Then
         Columns(x).Hidden = False
       Else
         Columns(x).Hidden = True
       End If
    Next
    End Sub
    I'm counting all 'X' in row 7 beginning from column D to the last column (which is AF in my case). All columns without an 'X' are hidden.
    It works as indented but a formula in my sheet gives me headache. It's this one:

    =SUM(COUNTIF(D7:AF7;{"X";"O"}))/COUNTA($D$2:$AF$2)
    I'm calculation the percentage of occuring 'X' and 'O' with it. The problem starts when I use the macro to hide some columns (which aren't marked with 'X') as the percentage stays the same -> it's still calculating it for all existing columns.
    What I wanted to achieve is a changing percentage based on the amount of VISIBLE columns. I tried to use sumproduct and subtotal but always ended up with #ref! or #value! errors, such as this one:

    =SUMPRODUCT(SUBTOTAL(103;INDIRECT(COLUMN(D:AF)&"7"))*(D7:AF7={"X";"O"}))/COUNTA($D$2:$AF$2)
    Hope you can guide me to the right direction
    Thanks in advance.

    Cheers,
    Mike
    Last edited by cyborg31; 02-17-2016 at 10:09 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. paste visible cells not working!!!!
    By meus in forum Excel General
    Replies: 4
    Last Post: 12-24-2014, 09:51 AM
  2. [SOLVED] how do you apply formatting to just visible cells?
    By ammartino44 in forum Excel General
    Replies: 4
    Last Post: 05-06-2014, 08:01 PM
  3. Apply COUNTIF to visible cells in a range
    By Belthasar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-21-2013, 05:15 AM
  4. [SOLVED] MAC - Paste only to visible cells not working
    By Lija in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 6
    Last Post: 05-13-2013, 10:57 AM
  5. Apply formula only to visible cells after filtering
    By excelnd in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-28-2012, 06:47 AM
  6. Apply formula only to visible cells
    By Fatboy10 in forum Excel General
    Replies: 2
    Last Post: 06-17-2012, 07:34 AM
  7. Copy visible cells macro not working
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2010, 10:07 AM

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