2

I have a workbook with several sheets.

One of the sheets "Calc" summarizes the data for 8 spark lines I have presented on a summary page based on an employee ID number entered on the summary page.

I have a created DO-loop macro to run this summary sheet by employee ID# and convert to a PDF and save by ID number.

Works like a charm and saves hours of time (literally). Trouble is two of the spark lines will not update.

I feel like Excel going to fast to allow them to update.

I have tried to put in a delay, Application.Wait(Now + TimeValue("00:00:01")), and have gone up to two minutes... No luck. Any ideas?

Option Explicit

Sub PDFtool()

    On Error GoTo errorHandle:

    Dim i As Integer
    i = 2

    Dim main, dataname, path, filename, ID As String

    path = Cells(5, 4)
    main = ActiveWorkbook.Name

    filename = ActiveWorkbook.path & "\" & "PDF files " & Format(Now(), "yyyy mm dd hh mm")
    MkDir filename

    Workbooks.Open filename:=path
    dataname = ActiveWorkbook.Name

    Do
        Worksheets("AM Location & ID#").Activate
        If Cells(i, 1) = "" Then Exit Do
        ID = Cells(i, 3)
        Worksheets("AM").Activate
        Cells(190, 1) = ID

        Worksheets("AM").Calculate

        ActiveSheet.ListObjects("Table33").Range.AutoFilter Field:=1, Criteria1:= _
        "TRUE"
        Columns("H:N").Select
        Selection.EntireColumn.Hidden = True

        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _ 
            filename:=filename & "/" & ID & ".pdf", _ 
            Quality:=xlQualityStandard, IncludeDocProperties:=True, _  
            IgnorePrintAreas:=False, OpenAfterPublish:=False                                        

        Columns("G:S").Select
        Selection.EntireColumn.Hidden = False
        ActiveSheet.ListObjects("Table33").Range.AutoFilter Field:=1

        i = i + 1

    Loop

    Application.ScreenUpdating = True

    End


    errorHandle:
        Application.ScreenUpdating = True
        MsgBox ("ERROR! Call Greg")
        End

End Sub
MacroMarc
  • 3,214
  • 2
  • 11
  • 20
Greg Mason
  • 21
  • 2

0 Answers0