我正在尝试创建一个宏,将识别和PDF个人银行家的投资组合。宏将过滤银行家的姓名(仅显示他们的投资组合),并在PDF文件中显示银行家的姓名。宏运行时没有任何错误。它能够识别银行家,添加到集合中,并过滤所有银行家。然而,它不会PDF任何东西。我还没能确定问题所在。请帮帮我!
我的代码:
Sub CreatePDFs()
'
' CreatePDFs Macro
'
' Identify distinct banker names in Column E and store in a collection
Dim BankerCollection As Collection
Dim Banker As Variant
Dim Rng As Range
Dim Cell As Range
Set Rng = Range("E5", Range("E5").End(xlDown))
Set BankerCollection = New Collection
On Error Resume Next
For Each Cell In Rng.Cells
BankerCollection.Add Cell.Value, CStr(Cell.Value)
Next Cell
' Loop through each banker name in the collection
For Each Banker In BankerCollection
' Copy each banker name to cell B1
Range("B1").Value = Banker
Range("B1").Font.Bold = True
' filter on the banker name, and PDF with banker name in document title
Range("E4", Range("E4").End(xlDown)).AutoFilter Field:=1, Criteria1:=Banker, VisibleDropDown:=False
ThisFile = Banker + " Portfolio"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisFile, OpenAfterPublish:=True
Next Banker
End Sub发布于 2017-10-13 02:43:04
更改代码的这一行
ThisFile = Banker + " Portfolio"有了这个
ThisFile = Banker & " Portfolio"P.S事实证明,您不必进行此更改,您的代码无需更改即可正常运行。
https://stackoverflow.com/questions/46716357
复制相似问题