|
谢谢老师分享优秀作品!
学习下,老师的代码。
'菜单数据随区域大小自动修改
'自动下拉不用点选箭头。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ML As New multilevel
Dim s As String, i As Integer
ML.DataList = Sheet3.[a2].CurrentRegion.Value '菜单数据随区域大小自动修改
If Target.Column = 1 Then
Application.SendKeys "%{down}" '自动下拉不用点选箭头。
ML.Lists Target
Else
Application.SendKeys "%{down}" '自动下拉不用点选箭头。
For i = 1 To Target.Column - 1
If Cells(Target.Row, i) <> "" Then
If s = "" Then
s = Cells(Target.Row, i)
Else
s = s & "," & Cells(Target.Row, i)
End If
Else
' MsgBox "上级菜单不能为空"
Exit Sub
End If
Next
ML.Lists Target, s
End If
End Sub
|
|