Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2922|回复: 16

[已解决]求教。下拉列表,宏。错误

[复制链接]
发表于 2011-5-29 20:13 | 显示全部楼层 |阅读模式
Private Sub 小包装_Change()
If IsEmpty(Cells(Selection.Row, 2)) = True Then
Cells(Selection.Row, 2) = 小包装.value
Cells(Selection.Row, 3) = "小"
End If
小包装.value = "包装方法"
End Sub
                                      OK !
=============================
Private Sub 完成状态_Change()
Cells(Selection.Row, 8) = 完成状态.value
完成状态.value = "完成的状态"
End Sub
     结果总是 "完成的状态"
  
???  求教               EXCEL 2003 . VB 6.0
END 解决不了
文件.rar (18.89 KB, 下载次数: 8)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2011-5-29 20:23 | 显示全部楼层
中间的
  1. 完成状态.Value = "完成状态"
复制代码
改成:
  1. 完成状态.Value = 完成状态
复制代码
回复

使用道具 举报

 楼主| 发表于 2011-5-29 20:31 | 显示全部楼层
本帖最后由 砂海 于 2011-5-29 20:33 编辑

Private Sub 系列1_Change()
If IsEmpty(Cells(Selection.Row, 3)) = True Then
Cells(Selection.Row, 3) = 系列1.Value
Cells(Selection.Row, 4) = "大"
End If
系列1.Value = "系列1"
End Sub

Private Sub 完成状态_Change()
With Cells(Selection.Row, 7)
.Value = 完成状态.Value
End With
完成状态.Value = 完成状态
End
End Sub可以用了,但是效果差了。达不到“系列1”  的效果
回复

使用道具 举报

发表于 2011-5-29 20:31 | 显示全部楼层
和系列1_Change一样,加个IF
Private Sub 完成状态_Change()
    If IsEmpty(Cells(Selection.Row, 7)) Then
        With Cells(Selection.Row, 7)
            .Value = 完成状态.Value
        End With
    End If
    完成状态.Value = "完成状态"
    End
End Sub
回复

使用道具 举报

发表于 2011-5-29 20:37 | 显示全部楼层
砂海 发表于 2011-5-29 20:31
Private Sub 系列1_Change()
If IsEmpty(Cells(Selection.Row, 3)) = True Then
Cells(Selection.Row, 3) ...

理解你的意思了。
就是说选择完完成状态之后,那个下拉列表的显示仍旧是完成状态。
那么就是先进行下判断:
  1. If IsEmpty(Cells(Selection.Row, 7)) Then
复制代码
然后END IF之后再将
  1. 完成状态.Value = "完成状态"
复制代码
最后倒数第二行的END可以去掉的
回复

使用道具 举报

 楼主| 发表于 2011-5-29 20:58 | 显示全部楼层
回复 放浪形骸 的帖子

Private Sub 系列1_Change()
If IsEmpty(Cells(Selection.Row, 3)) = True Then
Cells(Selection.Row, 3) = 系列1.Value
Cells(Selection.Row, 4) = "大"
End If
系列1.Value = "系列1"
End Sub
Private Sub 完成状态_Change()
If IsEmpty(Cells(Selection.Row, 9)) = True Then
Cells(Selection.Row, 7).Value = 完成状态.Value
Cells(Selection.Row, 8).Value = "不需要的过程"
'                     希望去掉 Cells(Selection.Row, 8).Value = "不需要的过程"
'                     if 判断也是不需要的
End If
完成状态.Value = "完成状态"
End Sub

回复

使用道具 举报

发表于 2011-5-29 21:01 | 显示全部楼层
砂海 发表于 2011-5-29 20:58
回复 放浪形骸 的帖子

Private Sub 系列1_Change()

要去掉IF判断还是说Cells(Selection.Row, 8).Value = "不需要的过程"???
去掉的话就直接删除就好了啊
回复

使用道具 举报

 楼主| 发表于 2011-5-29 21:02 | 显示全部楼层
回复 放浪形骸 的帖子

去掉的话,就得不到希望的结果。
回复

使用道具 举报

 楼主| 发表于 2011-5-29 21:11 | 显示全部楼层
回复 放浪形骸 的帖子

用If,是为了有End if

如果 Cells(Selection.Row, 8).Value = "不需要的过程"   取消的话 ,好像又循环赋值了。

简单说就是要结束Cells(Selection.Row, 7)的赋值状态。以便完成状态.Value = "完成状态"


回复

使用道具 举报

发表于 2011-5-29 22:36 | 显示全部楼层
砂海 发表于 2011-5-29 21:11
回复 放浪形骸 的帖子

用If,是为了有End if

有IF才有END IF
  1. Private Sub 完成状态_Change()
  2. If IsEmpty(Cells(Selection.Row, 7)) = True Then Cells(Selection.Row, 7).Value = 完成状态.Value
  3. 完成状态.Value = "完成状态"
  4. End Sub
复制代码
这样就好了?
可以了么?

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-23 18:36 , Processed in 0.333489 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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