VBA Error Code '5' Invalid procedure call or argument

LH2022

New Member
Joined
Jun 24, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm hoping someone can help.

I don't have a lot of experience with creating macros on Excel but I have been following a tutorial to create tabs in a sheet. The idea is when someone selects one of the tabs for example, sale by revenue/sales by units, the relevant graph will appear. The code which I have been given is as below and it works for the guy in the tutorial but not for me and I don't know why!

I hope someone can help me work out where I am going wrong! 🤦‍♀️

VBA Code:
Sub Display_Tab_Sales_Revenue()

    With ActiveSheet
   
        'Visibility of Tab Buttons
        .Shapes("Units_Inactive").Visible = True
        .Shapes("Units_Active").Visible = False
        .Shapes("Revenue_Inactive").Visible = True
        .Shapes("Revenue_Active").Visible = False
       
        'Visibility of Tab Contents
        .Shapes("Line_Chart_Revenue").Visisble = True
        .Shapes("Line_Chart_Unit").Visible = False

    End With
           
End Sub

Sub Display_Tab_Sales_Units()

    With ActiveSheet

        'Visibility of Tab Buttons
        .Shapes("Units_Inactive").Visible = False
        .Shapes("Units_Active").Visible = True
        .Shapes("Revenue_Inactive").Visible = False
        .Shapes("Revenue_Active").Visible = True
       
        'Visibility of Tab Contents
        .Shapes("Line_Chart_Reveue").Visible = False
        .Shapes("Line_Chart_Unit").Visible = True
       
    End With
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You have a typo here:

Rich (BB code):
.Shapes("Line_Chart_Revenue").Visisble = True
 
Upvote 0
You have a typo here:

Rich (BB code):
.Shapes("Line_Chart_Revenue").Visisble = True
Oh jeez! I have updated this and ran it again and now I get the following

"System Error &H80070057 (-2147024809)"
 
Upvote 0
That means you don't have a shape with the specified name. Double check them carefully.
 
Upvote 0
Glad we could help. :)

Welcome to the forum, by the way!
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,945
Members
449,198
Latest member
MhammadishaqKhan

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