| 
    
     |  | はじめまして。VBA初心者です。 横列にフィルタ処理をかけたく、検索していたら下記のコードを見つけたのでテストをしてみましたが、実行を押すと処理がとても遅いので「範囲を絞る」ということを試してみたいのですが
 C4〜ZZ100の範囲内で検索処理をしたい。といった場合には下記のコードにどのように追記すればよろしいでしょうか?
 
 
 Dim rowno, colno As Integer
 
 '=================================================
 'フィルタ処理
 '=================================================
 Private Sub CommandButton1_Click()
 Dim colAlfa, compData As String
 
 With UserForm1.ListBox1
 If .ListIndex < 0 Then
 .ListIndex = 0
 End If
 
 selectedvalue = .List(.ListIndex, 0)
 For i = colno To Columns.Count
 nowcol = Cells(1, i).Address(True, False)
 colAlfa = Left(nowcol, InStr(nowcol, "$") - 1)
 
 If Columns(colAlfa).Hidden = False Then
 If TypeName(Cells(rowno, i).Value) = "Integer" Then
 compData = Trim(Str(Cells(rowno, i).Value))
 Else
 compData = Cells(rowno, i).Value
 End If
 If compData = selectedvalue Then
 Columns(colAlfa).Hidden = False
 Else
 Columns(colAlfa).Hidden = True
 End If
 End If
 Next i
 End With
 Unload UserForm1
 End Sub
 
 '=================================================
 'クリア処理
 '=================================================
 Private Sub CommandButton2_Click()
 Dim colAlfa As String
 
 For i = 1 To Columns.Count
 nowcol = Cells(1, i).Address(True, False)
 colAlfa = Left(nowcol, InStr(nowcol, "$") - 1)
 Columns(colAlfa).Hidden = False
 Next i
 
 Unload UserForm1
 
 End Sub
 '=================================================
 '初期化処理
 '=================================================
 Private Sub UserForm_Initialize()
 '選択行
 rowno = ActiveCell.Row
 '初期カラム
 colno = ActiveCell.Column + 1
 
 'リスト作成
 For i = colno To Columns.Count
 If UserForm1.ListBox1.ListCount = 0 Then
 UserForm1.ListBox1.AddItem Cells(rowno, i).Value
 Else
 flg = False
 For j = 0 To UserForm1.ListBox1.ListCount - 1
 If Cells(rowno, i).Value = UserForm1.ListBox1.List(j) Then
 flg = True
 Exit For
 End If
 Next
 If flg = False Then UserForm1.ListBox1.AddItem Cells(rowno, i).Value
 End If
 Next i
 
 End Sub
 
 |  |