怎么解决EXCEL发现二义性名称 5

PrivateSubListBox1_Change()w=ListBox1.List(ListBox1.ListIndex)IfActiveCell=wThenActiv... Private Sub ListBox1_Change()
w = ListBox1.List(ListBox1.ListIndex)
If ActiveCell = w Then
ActiveCell = ""
ElseIf ActiveCell Like w & ",*" Then
ActiveCell = VBA.Replace(ActiveCell, w & ",", "")
ElseIf ActiveCell Like "*," & w & ",*" Then
ActiveCell = VBA.Replace(ActiveCell, w & ",", "")
ElseIf ActiveCell Like "*," & w Then
ActiveCell = VBA.Replace(ActiveCell, "," & w, "")
Else
If Len(ActiveCell) = 0 Then
ActiveCell = w
Else
ActiveCell = ActiveCell & "," & w
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.Intersect(Target, [A3:A20]) Is Nothing Then Me.ListBox1.Visible = False: Exit Sub
If Target.Count > 1 Then Exit Sub
With Me.ListBox1
.Visible = True
.Top = Target.Top + Target.Height
.Left = Target.Left + Target.Width
.Height = Target.Height * 4
.Width = Target.Width * 1.2
.List = Array("A自用", "B商用", "C投资", "D其他")
End With
Target = ""
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.Intersect(Target, [B3:B20]) Is Nothing Then Me.ListBox1.Visible = False: Exit Sub
If Target.Count > 1 Then Exit Sub
With Me.ListBox1
.Visible = True
.Top = Target.Top + Target.Height
.Left = Target.Left + Target.Width
.Height = Target.Height * 4
.Width = Target.Width * 1.2
.List = Array("A第一次", "B第二次", "C第三次", "D三次以上")
End With
Target = ""
End Sub
怎么解决以上代码,发现二义性名称
谢谢
展开
 我来答
户有美起了月8311
2014-07-09 · TA获得超过157个赞
知道答主
回答量:126
采纳率:100%
帮助的人:62.1万
展开全部
中毒了
解决办法
第一步.打开excel表,菜单-工具-宏-宏,将宏名对话框里的auto_open模块选中,点击右侧的删除按钮,保存文件,退出EXCEL
如果还出现的话继续第二步操作
第二步进入下面的文件夹,删除里面的文件
C:\Documents and Settings\Administrator\Application Data\Microsoft\Excel\XLSTART

如果该文件夹不显示,说明文件夹被隐藏。
我的电脑-【工具】-【文件夹选项】-【查看】,选择里面的“显示和查看所有文件和文件以及不隐藏已知文件的扩展名”用搜索查找XLSTART文件,将文件里的*.slx文件删除(删除后在按以上步骤把文件隐藏即可)

希望能帮你解决问题!
追问
能否将两段代码合并呢??
WDZZYC
2014-07-09 · TA获得超过751个赞
知道小有建树答主
回答量:849
采纳率:69%
帮助的人:407万
展开全部
Private Sub ListBox1_Change()
w = ListBox1.List(ListBox1.ListIndex)
If ActiveCell = w Then
ActiveCell = ""
ElseIf ActiveCell Like w & ",*" Then
ActiveCell = VBA.Replace(ActiveCell, w & ",", "")
ElseIf ActiveCell Like "*," & w & ",*" Then
ActiveCell = VBA.Replace(ActiveCell, w & ",", "")
ElseIf ActiveCell Like "*," & w Then
ActiveCell = VBA.Replace(ActiveCell, "," & w, "")
Else
If Len(ActiveCell) = 0 Then
ActiveCell = w
Else
ActiveCell = ActiveCell & "," & w
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.Intersect(Target, [A3:A20]) Is Nothing and Target.Count > 1 Then
Me.ListBox1.Visible = False
Exit Sub
else
With Me.ListBox1
.Visible = True
.Top = Target.Top + Target.Height
.Left = Target.Left + Target.Width
.Height = Target.Height * 4
.Width = Target.Width * 1.2
.List = Array("A自用", "B商用", "C投资", "D其他")
End With
Target = ""
end if

If Application.Intersect(Target, [B3:B20]) Is Nothing and Target.Count > 1 Then Me.ListBox1.Visible = False
Exit Sub
else
With Me.ListBox1
.Visible = True
.Top = Target.Top + Target.Height
.Left = Target.Left + Target.Width
.Height = Target.Height * 4
.Width = Target.Width * 1.2
.List = Array("A第一次", "B第二次", "C第三次", "D三次以上")
End With
Target = ""
end if
End Sub
追问
按照你的方法,,单元格里面没有选项出现了哦!!这么办呢??我是要实现在A、B、C、D、列都实现下拉菜单多选
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式