设置下拉列表中列出的项目数

时间:2016-11-26 05:09:42

标签: excel excel-vba vba

当项目导出为PDF时,当前会显示一条消息。希望从下拉列表中获取项目总数以表示(导出y of x)的x值。目前有固定值。

Const SAVE_PATH = "C:\SC\"

Sub SCtoPDF()
    Dim inputRange As Range
    Dim cell As Range

    Set inputRange = Evaluate(Range("G11").Validation.Formula1)

    For Each cell In inputRange
        If cell.Value <> "" Then
            counter = counter + 1
            Application.StatusBar = "Exporting Scorecard: " & counter & " of " & "32"

            [G11] = cell.Value
            ActiveSheet.Calculate
            ActiveSheet.ExportAsFixedFormat _
                Type:=xlTypePDF, _
                Filename:=SAVE_PATH & cell.Value, _
                Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, _
                IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
        End If
    Next cell
End Sub

1 个答案:

答案 0 :(得分:0)

假设没有验证列表行为空:

inputRange.Rows.Count