|
>月が始まるのはD1から右へ
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
Dim Lp As Single, Wp As Single, Hp As Single
Dim C As Range
With Target
If .Count > 1 Then Exit Sub
If .Row > 1 Then Exit Sub
Lp = .Left: Wp = .Width * 2: Hp = .Height
End With
Cancel = True
Range("D1", Range("D1").End(xlToRight)) _
.EntireColumn.Hidden = False
With ActiveSheet.Buttons.Add(Lp, 0.1, Wp, Hp)
.Caption = "表示する項目を選択"
.Font.Size = 9
.OnAction = "Scl_MyM"
End With
With ActiveSheet.ListBoxes.Add(Lp, Hp + 1, Wp, Hp * 8)
For Each C In Range("D1", Range("D1").End(xlToRight))
.AddItem C.Value
Next
.MultiSelect = xlSimple
End With
End Sub
Sub Scl_MyM()
Dim i As Integer
If VarType(Application.Caller) <> 8 Then Exit Sub
ActiveSheet.Buttons(1).Delete
With ActiveSheet.ListBoxes(1)
If IsError(Application.Match(True, .Selected, 0)) Then
.Delete: Exit Sub
End If
For i = 1 To .ListCount
If .Selected(i) = False Then
Columns(i + 3).Hidden = True
End If
Next i
.Delete
End With
End Sub
どこが変更されたか、よく見て理解してください。
|
|