|
こんばんわ。
こんなんでええんとちゃいまっか?
Sub test()
Dim Target As String
Dim FoundCell As Range
Dim FirstAddress As String
If TypeName(Selection) = "Range" Then
If Selection.Rows.Count = 1 Then
Target = Application.InputBox("検索文字列入力", "検索", Type:=2)
If Target = "False" Then Exit Sub
With Intersect(Selection, ActiveSheet.UsedRange)
Set FoundCell = .Find(Target, LookIn:=xlValues)
If Not FoundCell Is Nothing Then
FirstAddress = FoundCell.Address
Do
FoundCell.EntireColumn.Hidden = True '見つかる都度非表示に
Set FoundCell = .FindNext(FoundCell)
If FoundCell Is Nothing Then Exit Do
If FoundCell.Address = FirstAddress Then Exit Do
Loop
End If
Set FoundCell = Nothing
End With
End If
End If
End Sub
それと、
>range(Join(FoundAddr, ",")).Select
↑これはアドレスが256文字以上(カンマ等込み)になるとエラーになりまっせ。
試してみてな。
ほな。
|
|