kttq.net
当前位置:首页 >> vBA whilE wEnD >>

vBA whilE wEnD

do '语句…… loop while a>0 '这种是先执行一次语句,再判断要不要循环。 while a>1 '语句…… wend '这是先判断要不要执行 do while a>1 '语句…… '这种形式同while...wend,但好处在于,这里随时可用exit do退出循环 loop do '语句…… loop untill ...

Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim z% z = Target.Row While (Cells(z, 1).Value "r") And (Cells(z, 1).Value "") z = z + 1 Wend Cells(z, 1).Select End Sub

是后一个if 少 end if 引起

for i=0 to 9 next -------------- while i0 wend --------------- do while i0 loop ---------------- do loop while i0 ------------------- do until i=0 loop -------------------- do loop until i=0 ----------------------

我这里提供两种思路: 各有优缺点: 'Option Explicit '用字典编写: Private Sub CommandButton1_Click() Dim d1 As New Dictionary, d2 As New Dictionary, d3 As New Dictionary Dim eRow%, R%, S%, T% '定义表名称 Sheets.Add after:=Sheets(1)...

下面的代码测试通过,希望对你有所帮助: Option ExplicitSub xxx() MsgBox rndstr("hello,测试")End SubFunction rndstr(ByVal s As String) As String Dim r As String Dim i As Integer r = "" While s "" i = 1 + Int(Rnd * (Len(s) - 1)) '...

u1=MID(A1,1,1)+MID(A1,2,1)+MID(A1,3,1) 拖到最下面 t1=if(u1=u1000,A1,"") 拖到最下面

Dim num As Integer Dim r As String Dim f As String '将f指定为你的文件的路径 f = "t.txt" num = FreeFile() Open f For Input As num While Not EOF(num) Line Input #num, r MsgBox (r) Wend

Sub test() Dim a, b, c a = [a1] Do While Len(a) > 1 For i = 1 To Len(a) b = b + Val(Mid(a, i, 1)) Next c = c & b: a = b: b = 0 Loop [b1] = cEnd Sub 代码写在模块中,点击图片看动画效果

例如从同一目录下导入名为 test的文本文件: Dim fn As Integer, i As Integer Dim MyStr As String fn = FreeFile Open ThisWorkbook.Path & "\test.txt" For Input As fn For i = 1 To 4 Line Input #fn, MyStr Next i = 1 While Not EOF(fn) ...

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