Consulting

Results 1 to 4 of 4

Thread: Help with Macros for Conditional display

  1. #1
    VBAX Newbie
    Joined
    Jul 2016
    Posts
    2
    Location

    Help with Macros for Conditional display

    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
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Newbie
    Joined
    Jul 2016
    Posts
    2
    Location
    This really helps me , however to "show all" I need to be able to undo the previous macro actions. Could you please help

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Add a new macro based on ShowOnlyRed to set all colours.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •