Solved

Excel formula to evaluate visible cells only

Posted on 2014-04-10
10
1,184 Views
Last Modified: 2014-04-11
Hello Experts.
I need your assistance.  I use the following formula to evaluate group description in column A of the cell above to determine if it is the same as the group description in current row.  If it is, assign value in column B of above row to current row.  If not equal, evaluate if column B cell above is a 1 or 2 and assign the opposite.

B3=IF(A3=A2,B2,IF(B2=1,2,1))

Example:
A      B
Car      1
Car      1
Car      1
Bike      2
Bike      2
Boat      1

I than use column B to setup conditional formatting that would highlight each group of 2’s to easily see when a grouping changed.

The problem is when filters are used the conditional formatting does not work correctly.  When Bike is filtered out the highlighting doesn't change as the non-visible cells are still being evaluated in the current formula.

Example of issue:
A      B
Car      1
Car      1
Car      1
Boat      1
 
Is there something I can add to the above formula that would only evaluate the cells visible?

Thank you for taking a look at my issue.  Hope you have a solution
0
Comment
Question by:dhemple
  • 5
  • 3
  • 2
10 Comments
 

Author Comment

by:dhemple
ID: 39992134
I'm getting the sense that this might not be possible??
0
 
LVL 22

Expert Comment

by:Flyster
ID: 39993299
When Bike is filtered out the highlighting doesn't change as the non-visible cells are still being evaluated in the current formula.
I'm guessing you're using something like =B2=2 in your conditional formating to highlight the cell. When you filter out bike, both bike entries will hide and you should not see any yellow. Your result should be as you listed above. It works in the attached. Were you expecting a different result?

Flyster
VisibleCells.xlsx
0
 
LVL 22

Expert Comment

by:Flyster
ID: 39993444
Or are you looking for Boat to change to 2 once the filter is applied? If so, I'm still working on that one!
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39993447
Hi,

You could do it with a User Defined Function

Function ToggleVisibleCells(CellToCompare As Range) As Boolean
Set myCell = Application.Caller
Idx = 0
Do
    Idx = Idx + 1
    Set myCellOffset = myCell.Offset(-Idx, 0)
    IsCellHidden = myCellOffset.Height = 0
Loop Until IsCellHidden = False

If CellToCompare.Offset(-Idx, 0) = CellToCompare Then
    ToggleVisibleCells = myCell.Offset(-Idx, 0)
Else
    ToggleVisibleCells = Not (myCell.Offset(-Idx, 0))
End If
End Function

Open in new window

Regards
VisibleCellsV1.xlsm
0
 

Author Comment

by:dhemple
ID: 39993836
Hello Flyster and Rgonzo and thank you both for taking a look at my issue.

Flyster, I'm looking for Boat to change to 2 once the filter is applied.  The conditional formating would than highlight any rows that contain a 2 in column B.  Conditinal formating formula is "=$B2=2".  The conditinal formating works.

Rgonzo, I'm not sure I fully understand the code you have provided, but it appears that it would control cell visibility.  I'm not seeing how this would help me with the conditional formating of the filtered data.  Code language is not my strength...  Would you please walk me through your thoughts on this will help.

Thank you both for taking a look at this.

It would be very helpful if a solution could be found.
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39993857
Hi,

Have adapted the conditional formatting

pls try

Regards
VisibleCellsV2.xlsm
0
 

Author Comment

by:dhemple
ID: 39993864
Thank you for your quick response.  You clearly understand what I'm trying to achieve.

I've tried the example you supplied and it works when I filter out "Boat", but it does not work correctly if I filter out "Car".

Any thoughts?
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39993885
In the mean time it is a new file
pls try

Regards
VisibleCellsV3.xlsm
0
 

Author Comment

by:dhemple
ID: 39993905
Rgonzo thank you so much!!!!!  You are awesome.....  it works!!!   There's no need for me to evaluate if row is a "1" or "2", as the code creates a TRUE or FALSE which is used in the conditional formating.

Cannot thank you enough.  Thank you!!!
0
 

Author Closing Comment

by:dhemple
ID: 39993907
This was a brain killer for me and Rgonzo made it seem so simple.  Thank you Rgonzo!!!!  you are awesome
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question