Trying to change shape visibility during worksheet activate event

bisel

Active Member
Joined
Jan 4, 2010
Messages
253
Office Version
  1. 365
Platform
  1. Windows
I am curious. Maybe someone can help me out here.

I have a a macro that runs when a worksheet is selected or activated. Here is the VBA code ...

VBA Code:
Private Sub worksheet_activate()

Dim reprotect As Boolean
Dim c As Range
Dim i As Integer
Dim validc As Boolean
Dim xPTable As PivotTable
Dim xPFile1 As PivotField
Dim xPFile2 As PivotField
Dim xStr As String

'Set photo column visibility based on if Excel supports picture in cell
    If Application.Build > 16529 Then
        Range("photocol_v").Value = "v"
        Range("photocol_x").Value = "v"
        Sheet1.Shapes("photohelp1").visible = True
        Sheet1.Shapes("photohelp2").visible = True
    Else
        Range("photocol_v").Value = "h"
        Range("photocol_x").Value = "h"
        Sheet1.Shapes("photohelp1").visible = False
        Sheet1.Shapes("photohelp2").visible = False
    End If
:
:
etc.

Here is my question ...

Upon sheet activation, the ranges called "photocol_v" and "photocol_x" assume the correct value based on the IF statement testing if Application.Build is greater than 16529. However the shape visibility for the two shapes called "photohelp1" and "photohelp2" always remain visible. Nothing happens when I select or activate the sheet. Just for grins and giggles, I placed the above code into a different private module with that worksheet and then the visibility runs as it is supposed to do.

What is going on with activation event of the worksheet that shape visibility is not working?

Regards,

Steve
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Difficult to determine without having a copy of your workbook to review.
 
Upvote 0

Forum statistics

Threads
1,225,493
Messages
6,185,311
Members
453,287
Latest member
Emeister

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