Run Macro from hidden sheet

Akashwani

Well-known Member
Joined
Mar 14, 2009
Messages
2,911
Good day I have the following Macro....

Code:
Sub Wright()
'
' Wright Macro
'
'
    ActiveSheet.Shapes("Object 5").Select
    Selection.Verb Verb:=xlPrimary
End Sub

What do I need to add to this so that the Macro will run when the sheet is hidden? The Macro runs an Embeded presentation, which I do not want to be visible in the workbook.

Thanks

Ak
 
You can't Activate a hidden sheet (or a cell on it). Try the untested:

Code:
Public Sub Workbook_Open()
    Dim datatoFind
    Dim sheetCount As Integer
    Dim counter As Integer
    Dim Cell As Range
    On Error Resume Next
    datatoFind = InputBox("Please Type The Last Name of The Person You Are Searching For")
    If datatoFind = "" Then Exit Sub
    sheetCount = ActiveWorkbook.Sheets.Count
    If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
    For counter = 1 To sheetCount
        With Sheets(counter)
            Set Cell = .Cells.Find(What:=datatoFind, After:=.Cells(1, 1), LookIn:=xlFormulas, LookAt _
                :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                False)
                If Not Cell Is Nothing Then Exit Sub
        End With
    Next counter
    If Cell Is Nothing Then
        MsgBox ("Value not found")
    End If
End Sub
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
What Sheet should it be put in?

im afraid i didnt read you correctly. is it just not possible to do?

my goal is for a user to be able to find a name from the 'menu' sheet, while the database is hidden
 
Upvote 0
That code goes in the ThisWorkbook module. It loops around the worksheets looking for datatoFind without activating any sheets. If the find is successful Cell is a range object, otherwise it is Nothing. It's up to you to add some code if Cell is not Nothing, because I don't know what you want to do.
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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