2016-11-26 68 views
1

当项目导出为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 
+0

下拉什么?哪里? –

+0

'G11'的内容是什么? – CMArg

回答

0

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

inputRange.Rows.Count