Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Excel formula to evaluate visible cells only

Posted on 2014-04-10
10
Medium Priority
?
1,340 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 54

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 54

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 54

Accepted Solution

by:
Rgonzo1971 earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

810 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