gpt4 book ai didi

excel - VBA中的无效过程调用或参数错误

转载 作者:行者123 更新时间:2023-12-03 08:05:45 27 4
gpt4 key购买 nike

我收到此错误,我真的不知道为什么。

我有以下代码:

Rand = 2
LRand = ws.Cells(Rows.Count, 6).End(xlUp).Row
Do While Rand <> LRand + 1
If ws.Cells(Rand, 4).Value = "" Then
desch = InStr(ws.Cells(Rand, 5).Value, "(")
inch = InStr(ws.Cells(Rand, 5).Value, ")")
ws.Cells(Rand, 4).Value = Mid(ws.Cells(Rand, 5).Value, desch + 1, inch - desch - 1) 'here is the error
End If
Rand = Rand + 1
Loop

你们知道为什么我会收到无效的过程调用或参数吗?非常感谢!

最佳答案

有可能的

 if desch = 0
or
if inch = 0

desch = instr('this may return zero')
inch = instr('when it doesnt find the substring')

so putting them in mid functions results like these

mid(string,0,0) results error
mid(string(0,2) results error
mid(string(2,0) results error

所以首先检查那些值

关于excel - VBA中的无效过程调用或参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8064958/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com