Run macro only if condition is met.

  • Hi,
    I have following macro wich run 2 macros but I want to check if condition is met before this macro even start. In spreadsheet named "Arkusz1" i have pivot table named "Tabela przestawna2" wich when its empty macro shouldnt start and show msgbox "there is nothing to send". In addition this pivot table is allways filtered.


    Screenshot:
    https://zapodaj.net/0badb2b250f6e.png.html

    Code:


    Code
    Sub RunThemAll()
    
    
        Application.Run "vbaAutoRefreshPivot2"
        
        Application.Run "Notes_Email_Excel_Cells"    
       
    End Sub
  • Re: Run macro only if condition is met.


    Have you tried 'Isempty'?


    I don't use pivot but you can try something like this.


    Code
    Dim pvt As PivotTable
    Set pvt = ActiveSheet.PivotTables("Tabela przestawna2")
    
    
    If Not IsEmpty(pvt) Then
       RunThemAll
    End If
  • Re: Run macro only if condition is met.


    See if the following approach works for you.....

    Regards.
    sktneer

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!