0
我使用宏來檢查我在Excel中創建的發票之前保存它。目前,它拼寫檢查整個工作簿。我想拼寫檢查特定工作表的certian單元格(因爲我不想拼寫檢查發票上的人名和地址)。VBA拼寫檢查Excel中的特定單元格
具體來說,我想拼寫檢查只有細胞D15-D19上表「發票」和細胞D38上表「安全檢查」
有人能指出我在正確的方向?
這是我目前使用的是我希望優化VBA代碼:
Option Explicit
Sub SaveAsSafety()
'Saves filename as value of A1 plus the current date
Application.CommandBars("Tools").Controls("Spelling...").Execute
'Invokes spell check
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("M9").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = fName & " - " & Range("D10").Value & " - " & Range("D9")
' Change directory to suit your PC, including USER NAME
Sheets(Array("Safety Inspection", "Invoice")).Select
Sheets("Safety Inspection").Activate
ChDir _
"C:\Users\Brian\Google Drive\Buller Heating and Air\Invoices"
ActiveWorkbook.SaveAs Filename:=newFile
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("A1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub
你幾乎沒有。你已經有了正確的表單數組,你可以添加一個範圍地址數組,然後同時迭代它們中的兩個,收集表單和相應的範圍,在這個範圍內你的法術例程(你沒有包括在上面代碼) – user3598756