将下拉列表中的项目数量设置为variables

目前有项目正在导出为PDF时显示一条消息。 希望从下拉菜单中获得项目的总数,以表示(导出x的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 

假设没有validation列表行是空的:

 inputRange.Rows.Count