Office中国论坛/Access中国论坛

标题: [原创]求助:为什么说NEXT没有FOR [打印本页]

作者: wzwhu    时间: 2007-3-21 07:56
标题: [原创]求助:为什么说NEXT没有FOR
这是程序局部:

For k = 2 To 10000
                 If .Cells(k, 1).Value = "" Then Exit For
                 hr = Hour(.Cells(k, 1).Value)
                 mt = Minute(.Cells(k, 1).Value)
                 mo = .Cells(k, 9).Value
                 w = Val(.Cells(k, 10).Value) + 2
                 str1 = Cells(j, w).Value
                 
                 If Len(str1) > 16 Then
                 Cells(j, w).Value = Cells(j, w).Value + "HH"
                 
                 If Len(str1) > 16 And CStr(hr) >= 23 Then w = w + 1
                 Cells(j, w).Value = Cells(j, w).Value + CStr(hr) + ":" + Right("0" + CStr(mt), 2) + "    "
              Next k

当我没有粗体 If Len(str1) > 16 Then
                 Cells(j, w).Value = Cells(j, w).Value + "HH"

程序正常,一旦加进去就说NEXT没有FOR,下面同样的IF就没有问题,为什么这个就不行呢.

这个是别人以前写好的宏,似乎只要我修改都会报错,跪求高手指点!!!!!!!!!!!!!!!

[此贴子已经被作者于2007-3-20 23:57:10编辑过]


作者: 方漠    时间: 2007-3-21 17:12
For k = 2 To 10000
                 If .Cells(k, 1).Value = "" Then Exit For
                 hr = Hour(.Cells(k, 1).Value)
                 mt = Minute(.Cells(k, 1).Value)
                 mo = .Cells(k, 9).Value
                 w = Val(.Cells(k, 10).Value) + 2
                 str1 = Cells(j, w).Value
                 
                 If Len(str1) > 16 Then  Cells(j, w).Value = Cells(j, w).Value + "HH"

               
                 If Len(str1) > 16 And CStr(hr) >= 23 Then w = w + 1
                 Cells(j, w).Value = Cells(j, w).Value + CStr(hr) + ":" + Right("0" + CStr(mt), 2) + "    "
              Next k



漏END IF.




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3