i get a runtime error 13 during compilation. this is the line that throws up an
error, y = Application.counta(("A:A") <> "" - 3). I tried declaring y as a variant/ () didn't help either. could anyone please point out where i am making a mistake, that would be very helpful.
Option Explicit
Sub Test()
' z= no of rows(temp calc sheet emp id)
' x= no of columns(dashboard calender)
' y= no of rows(dashboard emp id)
Dim i, j, k, d, x, y, z As Long
Dim Empid As Long
Dim currentdate, startdate, enddate As Date
'Dim countA As Long
startdate = Worksheets("Temp calc").Range("C2")
enddate = Worksheets("Temp calc").Range("D2")
x = (Range("n2") - Range("n1"))
y = Application.counta(("A:A") <> "" - 3)
z = Worksheets("Temp Calc").counta(("A:A") - 1)
For i = 1 To y 'To loop through the emp_id in dashboard.
For j = 1 To x Step 1 'To loop through the calender in dashboard daywise.
For k = 1 To z 'To loop through the emp_id i temp calc sheet.
d = 0
Empid = Cells(4, i)
currentdate = Cells(3, 17 + j)
If (Cells(k, 1)) = Empid Then
If (currentdate > startdate) & (currentdate < enddate) Then 'To check whether the first column date falls within the project start and end date
d = d + 1
startdate = startdate + 1
enddate = enddate + 1
Cells(i + 3, j + 16) = d
End If
End If
Next
Next
Next
End Sub
如果要计算A列中的非空白单元格并从该数字中减去3,请尝试:
y = Application.WorksheetFunction.CountA(Range("A:A")) - 3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.