【发布时间】:2022-11-29 07:48:23
【问题描述】:
我对这段代码有疑问。最终,该模块应获取社区内的呼叫次数并将其与城市平均值进行比较。
这是块:
Option Explicit
Sub CallsAverage()
Dim neighbourhoodChoice(1 To 36) As Boolean
Dim summaryChoice(1) As Boolean
Dim neighbourhood As String, nCalls As Integer
Dim dataRange As Range, message As String
If frmOptions.ShowCallDialog(neighbourhood, nCalls) Then
If neighbourhoodChoice(1) Then
neighbourhood = "Allentown"
ElseIf neighbourhoodChoice(2) Then
neighbourhood = "Black Rock"
ElseIf neighbourhoodChoice(3) Then
neighbourhood = "BroadwayFillmore"
'INSERT MORE neighbourhoodChoice
ElseIf neighbourhoodChoice(35) Then
neighbourhood = "West Hertel"
Else
neighbourhood = "West Side"
End If
With Worksheets(neighbourhood).Range("O4")
nCalls = Range(.Offset(1, 0), .End("O39")).Rows
If frmOptions.ShowCallDialog(neighbourhood, nCalls) Then
With .Offset(0, nCalls)
Set dataRange = Range(.Offset(0, 1), .End("P39"))
message = "The number of calls in" & neighbourhood & "in 2021 were" & vbCrLf
If nCalls > "P41" Then
MsgBox "The neighbourhood is less than the overall average, suggesting that it is less problematic or safer than most neighbourhoods in the city."
If nCalls < "P41" Then
MsgBox "The neighbourhood is more than the overall average, suggesting that it is more problematic or less safe than most neighbourhoods in the city."
If nCalls = "P41" Then
MsgBox "The neighbourhood is equal to the overall average, suggesting that it is no less or more problematic/safe than most neighbourhoods in the city."
End If
End With <-- Issue occurs here
End If
End With <-- Issue occurs here too
End If
End Sub
如果您发现我的代码有任何其他问题,非常感谢所有帮助!
【问题讨论】:
-
If nCalls > "P41" Then没有匹配的End If同样下面那个。End("O39")看起来也不对。
标签: excel vba compiler-errors