dxcq.net
当前位置:首页 >> vBA双循环 >>

vBA双循环

dim arr,i&,j&,irow%irow=activecell.rowredim arr(1 to 21,1 to 7)for i =1 to 21 for j=1 to 7 arr(i,j)=sheet4.cells(irow,(i-1)*7+9) nextnextarr 这个两维数组,每行是一产品的信息,列表头分别是类别、品牌、型号。。。。等 赋 值给表时,...

Sub cfkj() Dim i As Integer, j As Integer Dim sz(1 To 9, 1 To 9) For i = 1 To 9 For j = 1 To i sz(i, j) = j & "*" & i & "=" & i * j Next j Next i Range("A1:i9") = sz() End Sub

B列和C列对比,不是同行对比, 如果是要同行对比,代码改为如下 for i=2 to 5 if cells(i,2)=cells(i,3) then cells(i,3)=cells(i,2)*cells(i,3) next i Sub jing() For i = 4 To 9 For j = 2 To 5 If Worksheets("sheet2").Cells(i, 6).Value =...

代码:exit for 示例:for i=1 to 100 if i=50 then exit for end if next

For i = 1 To 3 x = 4 For j = 1 To 4 x = 3 For k = 1 To 2 x = x + 5 Next k Next jNext iMsgBox x这个题目很有可能是考试题目,只有考试才会出这样无聊的题目。 答案13,原因如下:无论I,J如何值多少,在进入K循环之前,X=3. 所以程序等价...

n=1 'i从1开始,到多少结束? for i=1 to n if len(cells(i,1))=0 then for j=1 to 5 cells(i,j)=j next j else for j=1 to 5 cells(i+1,j)=j next j end if next i 这个循环实现容易,可你这个算法是有问题的,如果第一行非空,那么第二行被赋...

while-Wend循环语句的语法格式为 While Wend 在VBA中执行WhiIe-Wend循环语句的过程是先判断逻辑表达式的值是否为True,如果为True则执行循环体并执行Wend语句,再返回While语句对逻辑表达式进行判断。直到逻辑表达式的值 为False时,不执行循环...

Sub 只控制一列自动循环粘贴() For i = 1 To 11 Step 2 [b15] = Cells(17 + i, "n") [b16] = Cells(17 + i, "m") Cells(17 + i, "o").Resize(2, 1).Value = [j9:J10].Value Next End Sub

vba中退出内存循环需要采用goto的方法 示例: dim i as integerdim j as integerfor i=0 to 5 '外层循环 for j=0 to 5 '内层循环 if j=1 then '如果j等于1,则跳出内层循环 goto la '跳到la标签处 end if next j la: '这里设置goto的标签,接着...

循环里面还套了一层循环吧

网站首页 | 网站地图
All rights reserved Powered by www.dxcq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com