excel vba使用工作表功能

excel vba使用工作表功能,vba,excel,Vba,Excel,您好,我有一个关于跨多个工作表实现WorksheetBunsion的快速问题。我不太明白为什么我的代码在这一行中产生应用程序定义或对象定义的错误 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 Intege

您好,我有一个关于跨多个工作表实现WorksheetBunsion的快速问题。我不太明白为什么我的代码在这一行中产生应用程序定义或对象定义的错误

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
Dim ws As工作表
尺寸i为整数,j为整数,k为整数,x为整数,y为整数,z为整数
将lastrow设置为整数,将lastcoln设置为整数
黯然失色
Dim计数为整数,总计为整数
lastrow=Sheet2.UsedRange.Row-1+Sheet2.UsedRange.Rows.count
lastcoln=Sheet2.UsedRange.Column-1+Sheet2.UsedRange.Columns.count
对于此工作簿中的每个ws。工作表
如果ws.Name“图例”和ws.Name“主计划”,则
lastrow=ws.UsedRange.Rows.count
ws.Range(“A”&lastrow+1)=“机组总数:”&lastrow-1
对于j=6至lastcoln
count=Application.WorksheetFunction.CountBlank(ws.Range(单元格(2,6),单元格(14,6)))
下一个j
如果结束
下一个ws

谢谢你的帮助。非常感谢

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))
<!非常感谢!