2015-05-29 78 views
0

嗨,我只是有一個關於在多個工作表實現工作表功能的快速問題。我不明白爲什麼我的代碼在這一行excel vba與工作表功能

count = Application.WorksheetFunction.CountBlank(ws.Range(Cells(2, 6), Cells(14, 6))) 

生產應用程序定義或對象定義的錯誤我的代碼的一部分如下所示

Dim ws As Worksheet 
Dim i As Integer, j As Integer, k As Integer, x As Integer, y As Integer, z As Integer 
Dim lastrow As Integer, lastcoln As Integer 
Dim rowht As Double 
Dim count As Integer, total As Integer 

lastrow = Sheet2.UsedRange.Row - 1 + Sheet2.UsedRange.Rows.count 
lastcoln = Sheet2.UsedRange.Column - 1 + Sheet2.UsedRange.Columns.count 

For Each ws In ThisWorkbook.Worksheets 
If ws.Name <> "Legend" And ws.Name <> "Master Schedule" Then 
lastrow = ws.UsedRange.Rows.count 
ws.Range("A" & lastrow + 1) = "Total Crew Count: " & lastrow - 1 
For j = 6 To lastcoln 

count = Application.WorksheetFunction.CountBlank(ws.Range(Cells(2, 6), Cells(14, 6))) 

Next j 
End If 
Next ws 

感謝您的任何幫助。不勝感激!

+0

這個問題本身不是一個重複,但同樣的答案適用。 – FreeMan

+0

明白!非常感謝! – Francis

回答

0

變化count = Application.WorksheetFunction.CountBlank(ws.Range(Cells(2, 6), Cells(14, 6)))count = Application.WorksheetFunction.CountBlank(ws.Range(ws.Cells(2, 6), ws.Cells(14, 6)))