2016-11-26 64 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