If range contains "x", Then show/hide image VBA

suptechguy

New Member
Joined
Jan 15, 2020
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm looking for a way to have a VBA macro to look at a range of cells, determine if the value 'x' appears in the row; if Yes then hide image, if no then show image.

So the macro will be on sheet ("Upload Data") - commandbutton1
If worksheets("Prepared File").range("9:9") contains an "x", then hide image ("Smile")
If there is no "x" in the range, then show image ("Smile")

Could someone please help me?

Thank you!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hello,

How about something like this?
VBA Code:
Sub Toggle_Smile_Image()
    Dim ws As Worksheet
    
    Set ws = Sheets("Upload Data")
    
    If Application.WorksheetFunction.CountIf(Range("9:9"), "x") Then
        ws.Shapes("Smile").Visible = False
    Else
        ws.Shapes("Smile").Visible = True
    End If
End Sub

Let me know if it works
Cheers
Caleeco
 
Upvote 0
Hello, i have a similar problem in VBA.
I hope someone can help me.
I want to hide all rows which have a certain value in column "C". But this value is dependent on two other values.
If column "B" contains the value "ABC" and column "U" > 100 then hide this row and hide all other rows that have the same value in cell "C"

Is anyone able to solve this problem?
Thank you very very much!!
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top