Excel VBA Macro: Save Active Sheet As Multiple PDFs (Based on List of Cell Values)

Поделиться
HTML-код
  • Опубликовано: 6 сен 2024

Комментарии • 14

  • @dbo_prime
    @dbo_prime 2 года назад

    Dude, you taught me something I've been looking to do for about a month. Please keep it up as I learn easier the way you explain. Thanks.

    • @greggowaffles
      @greggowaffles  2 года назад

      Will do! Thanks for the motivation!!

  • @tonio909
    @tonio909 2 года назад +1

    Good video - very helpful. I was struggling getting something similar w/out the save as dialog. Your instructions helped perfectly.

    • @greggowaffles
      @greggowaffles  2 года назад

      So glad to hear that!! Thanks for watching!!

  • @Wilsonthepi
    @Wilsonthepi 2 года назад

    I'm brazilian, but don't write good english: You make great video. I'm in love with you. I love you. Congratulations.

  • @kashmoney1
    @kashmoney1 2 года назад +2

    Great video - can you please help if I want to save these in excel workbook instead of PDFs? this would really what I'm looking for Greg! I look forward to your response!

  • @Vishuiyer90
    @Vishuiyer90 2 года назад +3

    How do I save the filtered data in Excel instead of PDF?

  • @melissagarcia8921
    @melissagarcia8921 3 года назад +1

    thanks for this video. it save the day. how about filtering the in between number. like from 1 to 10 as cell / data value to filter from the "list" sheet and selecting the path of the file?

  • @ericellis6155
    @ericellis6155 Год назад

    Very helpful. When I try to execute this, it only saves the first 2 regions as pdfs. Any suggestions?

  • @johnlaymon3
    @johnlaymon3 Год назад

    Thank you so much for your help! I have been watching your videos and playing with code the past two days and was able to use this and the other code you have for copying into excel to make a loop for this but export to Excel. The only thing different is I made the data validation list in A1 on sheet 1 and then my column for region was named organization and I changed it to be under Column A(2).
    Sub copy_data_2_new_book()
    Dim count_col As Integer
    Dim count_row As Integer
    Dim og As Worksheet
    Dim wb As Workbook
    Dim organization As String
    Dim i As Long
    Set Data = ThisWorkbook.Sheets(1)
    Set List = ThisWorkbook.Sheets(2)
    'count numnber of regions
    List.Activate
    Count = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlDown)))
    Data.Activate
    For i = 1 To Count
    'updating the region name
    organization = List.Cells(i, 1).Text
    Data.Cells(1, 1) = organization
    Set og = Sheet1
    organization = og.Cells(1, 1).Value
    Set wb = Workbooks.Add
    wb.Sheets("Sheet1").Name = organization
    og.Activate
    count_col = WorksheetFunction.CountA(Range("A2", Range("A2").End(xlToRight)))
    count_row = WorksheetFunction.CountA(Range("A2", Range("A2").End(xlDown)))
    ActiveSheet.Range("A2").AutoFilter Field:=1, Criteria1:=organization
    'copies data from sheet to workbook
    og.Range(Cells(1, 1), Cells(count_row, count_col)). _
    SpecialCells(xlCellTypeVisible).Copy
    wb.Sheets(organization).Cells(1, 1).PasteSpecial xlPasteValues
    wb.Sheets(organization).Cells(1, 1).PasteSpecial xlPasteFormats
    Application.CutCopyMode = False
    og.ShowAllData
    og.AutoFilterMode = False
    wb.Activate
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("A1").Select
    'save and close
    On Error Resume Next
    Application.DisplayAlerts = False
    wb.SaveAs "/Users/p00082221/My Drive (p00082221@houstonisd.org)/PCIM/Reporting 22-23/Campus Data Reports/To Be Sorted/" & _
    organization & " " & Format(Date, "mm-dd-yyyy") & ".xlsx"
    Application.DisplayAlerts = True
    wb.Close 'savechanges:=False
    Next i
    End Sub

  • @enderwiggin2917
    @enderwiggin2917 2 года назад

    This is exactly what I was looking for. Liked and subscribed. Thanks a lot!

  • @AF-xl5lr
    @AF-xl5lr 9 месяцев назад

    good