mac excel vba loop : from list & then export as pdf

后端 未结 1 436
迷失自我
迷失自我 2020-12-04 03:52

So lost myself in this: I have a list on one sheet (studentlist) that has 160 student numbers. Would like to paste each student number in cell A1 ion the Feedback sheet and

相关标签:
1条回答
  • 2020-12-04 04:25

    I'm not a MAC user so I may be missing some restrictions I don't have in Windows OS, but you may be after something like follows:

    Option Explicit
    
    Sub Pdfexportmacro()
    
        Dim rCell As Range, rRng As Range
    
        'Student numbers in cells A7:A160
        Set rRng = Worksheets("studentlist").Range("A7:A160") '<--| set your "students" range
    
        With Worksheets("Feedback") '<--| reference "Feedback" worksheet
            For Each rCell In rRng '<--| loop through "students" range
                .Range("A1").Value = rCell.Value '<--| write current student number to cell A1 on Feedback sheet
    
               ' Export & save file as pdf using SNum as filename:
                .ExportAsFixedFormat Type:=xlTypePDF, fileName:= _
                "Macintosh HD:Users:Michael:Desktop:" & rCell.Value, Quality:= _
                xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
            Next rCell
        End With
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题