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 这个两维数组,每行是一产品的信息,列表头分别是类别、品牌、型号。。。。等 赋 值给表时,...

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 =...

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

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

用遍历区域就好,代码如下: Public Sub 两次组合() Dim DQrng As Range, CXrng As Range, XRrng As Range, i As Long Set XRrng = Sheets("sheet3").Range("a1") For Each DQrng In Range("A1:G1") i = 0 For Each CXrng In Range("A2:G2") XRr...

Dim aim As Worksheet Set aim = Sheets("RE Database") Dim i As Integer Dim j As Integer If M_type.Text = "" Then Exit Sub Else For i = 3 To 200 If Me.M_level1.Text = aim.Cells(5, i) Then For j = 5 To 100 If aim.Cells(j, i) "" Th...

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

excel vba一般有下面几种循环语句: 1、For ... Next for i=1 to 100 Cells(i,1)=i Next 2、Do Until ... Loop i=1 Do until i=100 Cells(i,1)=1 i=i+1 Loop 3、Do While ... Loop i=1 Do While i

Function mn(a)Dim m, n, l, sn As Integersn = 1For l = 1 To 35n = 0Don = n + 1For m = 2 To 6If l = Cells(a.Row - n, m) ThenGoTo 100End IfNext mLoop While a.Row - n > 3100If n > 12 Thensn = sn + 1End IfNext lmn = snEnd Function

通常有下面一些循环语句: 1、For ... Next 如: For i=1 to 100 Cells(i,1)=1 Next 2、Do Until .... Loop 如: i=1 Do Until i=100 Cells(i,1)=i i=i+1 Loop 3、Do Where ... Loop 如: i=1 Do Where i

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