サブから関数を呼び出していますが、機能しません。原因を突き止めるのに多くの時間を費やしましたが、私にはそれがわかりません。コンパイル エラーが発生します: 配列が必要です。
これがコード全体です。問題のある行についてコメントしました
サブ innout()
Dim numclosed As Long, numnew As Long
Dim lblvar As Variant
Dim tblcr As Range
Dim lrcr As Long
Dim finishdates As Range
Dim lastupdate As Long, msg As Long
Sheets("combined_report").Select
lrcr = ActiveSheet.Range("A1").Offset(ActiveSheet.Rows.count - 1, 0).End(xlUp).Row
tblcr = Range("A6:AB" & lrcr)
lastupdate = Range("F2").Value
finishdates = Range("T6:T" & lrcr)
For Each cell In finishdates
If cell.Value >= lastupdate And cell.Value < Date Then
If cell.Offset(0, -5).Value = "Completed" Then
numclosed = numclosed + 1
End If
End If
Next
Sheets("Tasks_to_do").Select
Dim lrttd As Long
Dim r As Long
Dim numttd As Long
Dim svrange As Range
Dim resp As String, svname As String
lrttd = ActiveSheet.Range("A1").Offset(ActiveSheet.Rows.count - 1, 0).End(xlUp).Row
numnttd = lrttd - 1
Set svrange = Range("K2:K" & lrttd)
For Each cell In svrange
If cell.Value = "" Then
numnew = numnew + 1
resp = cell.Offset(0, -6).Value
'ERROR ON THIS LINE
cell.Value = svname(resp)
End If
Next
msg = MsgBox("*************************" & Chr(13) & "Items closed yesterday: " & numclosed & Chr(13) & "New items as of now: " & numnew, vbOKOnly, "Mproduct item activity")
サブ終了
関数 svname(resp As String) As String
Dim respdb As Range
lrs As Long
Sheets("Supervisors").Select
lrs = ActiveSheet.Range("A1").Offset(ActiveSheet.Rows.count - 1, 0).End(xlUp).Row
respdb = Range("A2:A" & lrs)
For Each cell In respdb
If cell.Value = resp Then
svname = cell.Offset(0, 1).Value
Exit Function
End If
Next
終了機能
よろしくお願いします!