VBA to automatically run another macro after report is ran

steve400243

Active Member
Joined
Sep 15, 2016
Messages
429
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello, thanks for any help that can be provided.

I use this msgbox code to run macro"t" when a user opens the workbook. After this is complete, I want another macro to run automatically without the select button.

VBA Code:
Private Sub Workbook_Open()
    If MsgBox("Hello, Would you like to Create a new report?", vbYesNo, "CFS DATA ANALYSIS REPORT") = vbYes Then Call t
End Sub

the other macro to autorun is "getuniques" and is in module2

Code:
Sub getuniques()
   Dim d As Object, c As Variant, i As Long, lr As Long
   Set d = CreateObject("Scripting.Dictionary")
   lr = Cells(Rows.Count, 1).End(xlUp).Row
   c = Sheets("Sheet1").Range("A2:A500" & lr).Value2
   For i = 1 To UBound(c, 1)
     If c(i, 1) <> "" Then d(c(i, 1)) = Empty
   Next i
   Sheets("ANALYSIS").Range("U3").Resize(d.Count) = Application.Transpose(d.Keys)
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try this.
VBA Code:
Private Sub Workbook_Open()
    If MsgBox("Hello, Would you like to Create a new report?", vbYesNo, "CFS DATA ANALYSIS REPORT") = vbYes Then 
        Call t
        Call getuniques
    End If
End Sub
 
Upvote 0
Norie, Thank you! that works as needed. I tried different combinations of this and could not get it to work. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,215,237
Messages
6,123,800
Members
449,127
Latest member
Cyko

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