我的代码碰到了
错误13:类型不匹配
无论何时我输入或更改C59中的值,C59都会包含此公式 `print(np.array([arr[2:4], arr[3:5]])) # same shape`
。我猜是因为变量不同,但不知道如何解决,非常感谢任何帮助!
print(np.array([arr[:2], arr[:3]]))
[array([[0, 1],
[2, 3]])
array([[0, 1],
[2, 3],
[4, 5]])]
答案 0 :(得分:0)
在除以C57
时,您需要确保0
不是C59
,在这种情况下,#DIV/0!
将是.Value
(错误)
如果单元格包含错误,则无法检查其C59
属性。
首先检查单元格If IsError(Worksheets("InvPL").Range("C59")) Then
Msgbox "C59 contains an error. If C57=0 then it is a divide by zero error."
Else
If Range("C59").Value = "0" Then
Sheets("InvPL").Rows("78:79").EntireRow.Hidden = True
Else
Sheets("InvPL").Rows("78:79").EntireRow.Hidden = False
End If
End If
中的错误:
With
或更干净的版本,使用Worksheets
块,并使用Sheets
代替 With Worksheets("InvPL")
If IsError(.Range("C59")) Then
Msgbox "C59 contains an error. If C57=0 then it is a divide by zero error."
Else
If .Range("C59").Value = "0" Then
.Rows("78:79").EntireRow.Hidden = True
Else
.Rows("78:79").EntireRow.Hidden = False
End If
End If
End With
,因为工作表也可以引用图表对象:
C57
如果您还想在发生错误时隐藏/取消隐藏这些行,则可以稍微更改逻辑。
另一种选择是更改公式,当0
为=IF(C57=0,0,ROUNDUP(D59/C57,0))
时返回零而不是错误:
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<ProgressBar
android:id="@+id/hamlebar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:max="100" />
<TextView
android:id="@+id/bartext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hamle"
android:layout_marginTop="10dp"
android:layout_gravity="center"
android:background="@android:color/transparent" />
</LinearLayout>