我有一个VBA代码,将表" Conversiepdf"转换为PDF。
问题是整个表由公式生成,一半的表格堆满了数据,另一半保持空白(> 运行公式但返回" )
我的代码转换了整个排长行1000并生成32页的整个表(Witch 30是空的 - 只有没有真实数据的桌子)
我需要它忽略公式返回的空白单元,如果从a到q的整个行为空或返回"。(如果一排仅一二个或三个单元格为空,则不应应用)
请帮助..
'This is my code till now:
Dim ThisRng As Range
Dim strfile As String
Dim myfile As Variant
'Selectie Sheet pentru conversie
With ActiveWorkbook.Sheets("ConversiePDF")
Set ThisRng = .Range("A2", .Cells(.Rows.Count, "F").End(xlUp))
End With
谢谢..
Private Sub CommandButton1_Click()
'BUTON CONVERSIE PDF - ANGAJATORI
'DESCRIPTION: CONVERSIE A UNUI SHEET IN PDF
Dim ThisRng As Range
Dim strfile As String
Dim myfile As Variant
'Selectie Sheet pentru conversie
Application.ScreenUpdating = False
ActiveWorkbook.Sheets("PDF ANG").Visible = True
'Selectie filtru pentru ce sa converteasca
ActiveWorkbook.Sheets("PDF ANG").Select
Selection.AutoFilter Field:=1, Criteria1:="<>" 'column A
Selection.AutoFilter Field:=5, Criteria1:="<>" 'column E
'Selectie raza pentru conversie
With ActiveWorkbook.Sheets("PDF ANG")
Set ThisRng = .Range("A2", .Cells(.Rows.Count, "F").End(xlUp))
End With
'Prompt for save location
strfile = "Selection" & "_" _
& Format(Now(), "yyyymmdd_hhmmss") _
& ".pdf"
strfile = ThisWorkbook.Path & "" & strfile
myfile = Application.GetSaveAsFilename _
(InitialFileName:=strfile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and File Name to Save as PDF")
If myfile <> "False" Then 'save as PDF
ThisRng.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
myfile, Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Else
MsgBox "No File Selected. PDF will not be saved", vbOKOnly, "No File Selected"
End If
ActiveWorkbook.Sheets("PDF ANG").ShowAllData
ActiveWorkbook.Sheets("PDF ANG").Visible = False
End Sub