Run macro on one sheet from another

GeoThornton96

New Member
Joined
Jul 5, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a macro on one sheet (A1) that I would like to run on that sheet(A1) but to be activated from another sheet (Home) if that makes sense. This is the code that I want to run and is on (A1).

VBA Code:
Sub HANDSET()
'
' HANDSET Macro
' Macro recorded 04/07/2020 by GThornton
'

'
    Selection.AutoFilter Field:=4, Criteria1:="HANDSET"
End Sub

and then on another sheet(HOME), I have a macro that hides and shows shapes but I also want it to run the macro above. I do know how to do this. this is the code for that

VBA Code:
Public Sub TypeHandset()
 




    If ActiveSheet.Shapes("Rectangle 12").Visible Then
        ActiveSheet.Shapes("Rectangle 12").Visible = False
        ActiveSheet.Shapes("Rectangle 13").Visible = False
        ActiveSheet.Shapes("Rectangle 14").Visible = False
        ActiveSheet.Shapes("Rectangle 15").Visible = False
        ActiveSheet.Shapes("Rectangle 16").Visible = False
        ActiveSheet.Shapes("Rectangle 17").Visible = False
    Else
        ActiveSheet.Shapes("Rectangle 12").Visible = True
        ActiveSheet.Shapes("Rectangle 13").Visible = True
        
    End If
    

   
   

End Sub

I am very new to VBA so sorry if my code is terrible. I appreciate the help
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
690
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi,
Instead of activesheet you maybe use:

VBA Code:
Dim oSht as worksheet
Set oSht = Sheets("A1")
....
oSht.AutoFilter....
or
oSht.Shapes("Rectangle 12") ...
....
Set oSht = nothing
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,123,261
Messages
5,600,587
Members
414,391
Latest member
Pandurang

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
Top