[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『コンボボックス検索』(ゆかり)エクセル2010 ウインドウズ7
マクロ初心者です
正直全然できていません
[[20131105121455]] の質疑を利用しようと思ったのですが
上手に出来ない為
教えてください
この質問の場合
シートsss対象に
コンボボックス6個の検索ですがsheet6でコンボボックス3個の場合の
マクロを教えていただけませんか
よろしくお願いします
ComboBox3が選択された時点で何がしたいのかわからないので、 とりあえず
Option Explicit
Private dic As Object
 Private Sub UserForm_Initialize()
     Dim a, i As Long, ii As Long
     Set dic = CreateObject("Scripting.Dictionary")
     dic.CompareMode = 1
     a = Sheets("sheet6").Cells(1).CurrentRegion.Resize(, 3).Value
     For i = 2 To UBound(a, 1)
         For ii = 1 To UBound(a, 2)
             a(i, ii) = CStr(a(i, ii))
         Next
         If Not dic.exists(a(i, 1)) Then
             Set dic(a(i, 1)) = CreateObject("Scripting.Dictionary")
             dic(a(i, 1)).CompareMode = 1
         End If
         If Not dic(a(i, 1)).exists(a(i, 2)) Then
             Set dic(a(i, 1))(a(i, 2)) = CreateObject("Scripting.Dictionary")
             dic(a(i, 1))(a(i, 2)).CompareMode = 1
         End If
         If Not dic(a(i, 1))(a(i, 2)).exists(a(i, 3)) Then
             Set dic(a(i, 1))(a(i, 2))(a(i, 3)) = _
             CreateObject("System.Collections.ArrayList")
         End If
         dic(a(i, 1))(a(i, 2))(a(i, 3)).Add i
     Next
     Me.ComboBox1.List = dic.keys
 End Sub
 Private Sub ComboBox1_Change()
     ClearComb 2, 3
     With Me
         If .ComboBox1.ListIndex <> -1 Then
             .ComboBox2.List = dic(.ComboBox1.Value).keys
         End If
     End With
 End Sub
 Private Sub ComboBox2_Change()
     ClearComb 3, 3
     With Me
         If .ComboBox2.ListIndex <> -1 Then
             .ComboBox3.List = dic(.ComboBox1.Value)(.ComboBox2.Value).keys
         End If
     End With
 End Sub
 Private Sub ClearComb(myStart, myEnd)
     Dim i As Long
     For i = myStart To myEnd
         Me.Controls("ComboBox" & i).Clear
     Next
 End Sub
(seiya) 2013/11/23(土) 17:52
 Private Sub ComboBox3_Change()
     Dim i As Long
     If Me.ComboBox3.ListIndex <> -1 Then
         With Sheets("Sheet6").Cells(1).CurrentRegion
             .Parent.AutoFilterMode = False
             For i = 1 To 3
                 .AutoFilter i, Me.Controls("ComboBox" & i).Value
             Next
         End With      
     End If
 End Sub
かな?(未検証) (seiya) 2013/11/23(土) 19:06
本当にありがとうございました
(ゆかり) 2013/11/23(土) 19:13
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
 Modified by kazu.