Good day. I need to find a way to set multiple ranges dynamically (I believe that's what it's called) and then save the data in each range to a separate pdf file that is named based on a specific cell value.

See example below.

Pic.jpg

I would like to set the range based on x's being placed in column A

The code I'm using to save the files as pdfs is as follows:

Sub SaveAsPDF()
    Dim ws As Worksheet
    Dim Fname As String
    For Each ws In ActiveWorkbook.Worksheets
    
    Application.ScreenUpdating = False
    
        On Error Resume Next 'Continue if an error occurs

        ' Name PDF files based on the worksheet Index (e.g Annex 1.1.1, Annex 1.1.2, etc.)
        Fname = "\\192.168.1.241\Behavioral Health Share\Weekly Reports\Data Sheets\" & ws.Name & " " & Format(Date, "MM-DD-YY") & ".pdf"

        ' If you want to name the PDF files differently just change the Fname variable above to
        ' whatever you like. For example if you changed Fname to:
        '
        '  Fname =  “C:\myFolder\pdfs\” & ActiveWorkbook.Name & "-" & ws.Name
        '
        '  The files would be stored in C:\myFolder\pdfs, and named using the
        ' spreadsheet file name and the worksheet name.
        '
        ' WARNING: Using worksheet names may cause errors if the  names contain characters that Windows
        ' does not accept in file names. See below for a list of characters that you need to avoid.
        '
        ws.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=Fname, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False
            
    Next ws

Application.ScreenUpdating = True

End Sub
Here is a mock up of my workbook.

TEST.xlsm

Thanks.