设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1759|回复: 1
打印 上一主题 下一主题

[原创]求助:为什么说NEXT没有FOR

[复制链接]
跳转到指定楼层
1#
发表于 2007-3-21 07:56:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这是程序局部:

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编辑过]

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2007-3-21 17:12:00 | 只看该作者
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.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-4-12 15:57 , Processed in 0.119263 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表