【ExcelVBA】 既にあるマクロの間で実行させたいのです。
こんにちは
下のマクロを・・・
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Const RangeName As String = "●入力"
If Not Intersect(Range(RangeName), Target) Is Nothing Then
Cancel = True
If Target = "●" Then
Target = ""
Else
Target = "●"
End If
End If
End Sub
このマクロの■ここで実行■で実行させたいのですが、どのようにしたらよいでしょう。
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address <> "$D$1" Then Exit Sub
Cancel = True
Columns("A:U").Select
Range("T1").Activate
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
Selection.Replace What:="ああ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D1").Select
End Sub
■ここで実行■
Private Sub Worksheet_Change(ByVal Target As Range)
strAddress = "A1:A2000"
On Error GoTo ErrorHandler
If Target.Count > 1 Then GoTo ErrorHandler
If Not Intersect(Target, Range(strAddress)) Is Nothing Then
Application.EnableEvents = False
Range(strAddress).ClearContents
Target.Value = "●"
End If
ErrorHandler:
Application.EnableEvents = True
End Sub
お礼
無事できました!ありがとうございました!!