当for循环到next时,tjm自动+1,注意你的语句:在循环过程中,如果Cells(5, tjm) 为空,你将tjm-2 然后又将tjm+1 如果Cells(5, tjm) 为空,在你-2又两次+1后,你的程序成了:for tjm=16 to 45 tjm=tjm-2 tjm=tjm+1 next tjm永远是原来的值,自然就死了。看...
Do While Cells(i, a) <> ""Cells(i, a) = ""i = i + 1 Loop i = 2 Do While Cells(i, a-7) <> ""If Cells(i, a-7) = Cells(1, a) Then if Cells(i + 1, a-7)<>"" then Cells(j, a) = Cells(i + 1, a-7)j = j + 1 end if End If i = i + ...
代码及注释如下:Sub main()f = Dir(ThisWorkbook.Path & "\*.xlsx")'搜索本文件下的所有xlsx格式文件(由于一般带VBA的文件不能保存为xlsx格式,故无需去判断,是否打开的是本文件)Do While f <> ""Workbooks.Open (ThisWorkbook.Path & "\" & f)'依次打开搜索到的文件Workbooks(f).Sheets(...
adInteger, _adParamInput)ADOCmd.Parameters.Append ADOPrmADOCmd.Parameters(sParmName).Value = 0Set ADORs = ADOCmd.ExecuteDo While (Not ADORs Is Nothing)If ADORs.State = adStateClosed Then Exit DoWhile Not ADORs.EOFFor i = 0 To ADORs.Fields.Count - 1rStr = rStr & " : " ...
Sub 排名()Dim MYARR(1 To 100, 1 To 3)Dim I, J, K, L As Integer Dim BJ, XM As String Dim CJ As Double I = 2 Do While Cells(I, 3) <> ""For J = 1 To 3 MYARR(I - 1, J) = Cells(I, J)Next J I = I + 1 Loop I = I - 2 For J = 1 To I -...
1)NextNextNextEndSub不知道你G10与H10是不是变量, 也不知道你说的A10显示数值是哪个值,反正循环公式就是下面,取值不对的话,类推好了...用公式之前,选工具,选项,重新计算,迭代计算前打勾,这样就可以循环计算了...=IF(G10=H10,A10,A10+0.1)doif cells(10,7)=cells(10,8) then exit do...
Sub 筛选2()Dim R As Range, R1 As RangeSet R = Columns("H").Find("fdm", LOOKAT:=xlWhole)Set R1 = RDo Until R1.Height = 0Set R = Columns("H").Find("fdm", R, LOOKAT:=xlWhole)R.EntireRow.Hidden = TrueLoopEnd SubWorksheets("Sheet1").Cells(1, 1).AutoFilter ...
sCaption As String = vbNullString)Dim hWndDesktop As LongDim hWnd As LongDim hProcThis As LongDim hProcWindow As LonghWndDesktop = GetDesktopWindowhProcThis = GetCurrentProcessIdDohWnd = FindWindowEx(hWndDesktop, hWnd, sClass, sCaption)GetWindowThreadProcessId hWnd, hProcWindowLoop ...
Do While n <> 0 a = n Mod 2 n = n \ 2 x = a & x Loop Do While Len(x) Mod 4 <> 0 x = "0" + x Loop Do While Len(x) > 0 Select Case Right(x, 4)Case "0000"y = "0" + y Case "0001"y = "1" + y Case "0010"y = "2" + y Case "0011"y =...
用for循环,依次判断每个分表的试样编号是否在汇总表存在,存在就等于过去