PDA

View Full Version : Help with Macros for Conditional display



prab76
07-13-2016, 08:32 AM
Hello


I am looking for some assistance writing macros to display the excel sheet according to the conditions I select . Please find the Excel requirement attached.


Depending on the Command Button, the excel cells should show the data either the Red Colored cells and remove all the other data, or the Cells with R letter or the Image with the Blue Sun or the Entire Data.


Can someone please help


Thanks

mdmackillop
07-13-2016, 12:11 PM
I'd suggest something like this partial solution

Sub ShowOnlyRed()
For Each cel In Range("Data")
With cel
If .Value = "red" Then
.Interior.ColorIndex = 3
Else
.Interior.ColorIndex = xlNone
End If
.NumberFormat = ";;;"
End With
Next
ActiveSheet.Shapes("Picture 1").Width = 0
End Sub




Sub ShowBlueSun()
For Each cel In Range("Data")
With cel
If .Value = "bluesun" Then
ActiveSheet.Shapes("Picture 1").Width = 25
ActiveSheet.Shapes("Picture 1").Left = .Left + 8
ActiveSheet.Shapes("Picture 1").Top = .Top - 3
Else
.Interior.ColorIndex = xlNone
End If
.NumberFormat = ";;;"
End With
Next
End Sub

prab76
07-13-2016, 01:36 PM
This really helps me , however to "show all" I need to be able to undo the previous macro actions. Could you please help

mdmackillop
07-13-2016, 01:49 PM
Add a new macro based on ShowOnlyRed to set all colours.