如何在 VB excel 2003 中迭代 MIN/MAX 函数中的单元格?
Set min=min1=1000, max=max1=position=0
For i=2 to 10 do
min=**MIN(A(i,j):A(i+5,j));**
if position=0 then min1=min, position=1 else
For j=2 to 10 do {max=**MAX(A(i,j):A(i+5,j));**
if max<min then next j else position=0, next i
我对此很陌生,并尝试在 VB excel 中执行上面的下一个代码(问题以粗体显示):谢谢
Set min=min1=1000, max=max1=position=0
For i=2 to 10 do
min=**MIN(A(i,j):A(i+5,j));**
if position=0 then min1=min, position=1 else
For j=2 to 10 do {max=**MAX(A(i,j):A(i+5,j));**
if max<min then next j else position=0, next i
I am new at this and trying to do next code above in VB excel(problem is bolded):Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
纠正所有代码是不可能的,因为不清楚您要做什么。但以下内容可能会给您一个开始。
最好声明变量并指定它们的类型:
我更喜欢按字母顺序声明它们,但这不是必需的。
你需要:
Set min=min1=1000, max=max1=position=0
存在以下错误:在某些语言中
min=min1=1000
表示min1=1000, min=min1
但在 VBA 中表示:没有
Do
位于 For 语句末尾。所以:MIN 和 MAX 是工作表函数。要在 VBA 中使用 then,您必须说它们是工作表函数。 VBA 中的语句末尾没有分号。您已在 MIN 函数中使用 j,但尚未设置其值。
我无法告诉 MIN 和 MAX 参数值的位置。
如果该位置位于当前工作表中,您需要类似:
或可能类似:
可以在数组上使用 MIN 和 MAX 函数,但我不知道如何选择数组的一部分。
希望这能给您一个开始。
It is impossible to correct all your code because it is not clear what you are trying to do. But the following might give you a start.
It is always best to declare your variables and to specify their type:
I prefer to declare them in alphabetic order but that is not a requirement.
You need:
There are the following mistakes in
Set min=min1=1000, max=max1=position=0
:In some languages
min=min1=1000
meansmin1=1000, min=min1
but in VBA it means:There is no
Do
at the end of a For statement. So:MIN and MAX are worksheet functions. To use then in VBA you have to say they are worksheet functions. There are no semicolons at the end of statements in VBA. You have used j in the MIN function but have not set its value yet.
I cannot tell the location of the values that are parameters to MIN and MAX.
If the location is in the current worksheet you need something like:
or perhaps like:
It is possible, to use the MIN and MAX functions on an array but I know of no way of selecting a portion of an array.
Hope this gives you a start.