advanced help
per page, with , order by , clip by
Results of 1 - 1 of about 978 for チェックボックス (0.008 sec.)
[[20190725045345]]
#score: 5499
@digest: f11e44e958dbbc020f289f688d1d9e94
@id: 80303
@mdate: 2019-07-25T00:07:22Z
@size: 5571
@type: text/plain
#keywords: grofile (236186), group1 (73452), group2 (60335), filter (16373), トケ (13187), キ") (10985), キ( (10586), トク (10128), ・ソ (7179), ・ホ (6303), 列中 (6177), クボ (5507), cells (3619), ム( (3529), ホッ (3343), ・プ (2700), macro2 (2612), チェ (2505), ーキ (2421), ・ア (2403), ェッ (2269), リー (1909), macro1 (1676), アイ (1560), グル (1542), ボッ (1488), array (1484), リン (1385), ック (1362), ・シ (1264), クス (1194), variant (1166)
チェックボックスにチェックしたら関連するものにもチェックを入れる』(くろ)
閲覧有難うございます。 初めて利用させていただきます。 現在作成中のVBAが初めて作成するものになります。 チェックボックスにチェックを入れたら関係するものにもチェックを入れたいのですが 関数の使用方法が間違っているのか「型が一致しません」と表示されます。 関数も型の宣言もよくわかっていないため何を間違っているのか、どう記述すればいいのかご教授ください。 例としては ----- グループ1(セルA1)(チェックボックスのリンクセルD1) ・ホットケーキ(セルA2)(チェックボックスのリンクセルD2) ・ソフトクリーム(セルA3)(チェックボックスのリンクセルD3) ・ショートケーキ(セルA4)(チェックボックスのリンクセルD4) グループ2(セルB1)(チェックボックスのリンクセルE1) ・アイスクリーム(セルB2)(チェックボックスのリンクセルE2) ・プリン(セルB3)(チェックボックスのリンクセルE3) ・クレープ(セルB4)(チェックボックスのリンクセルE4) ----- でソフトクリームにチェックを入れたらアイスクリームにもチェックが入ったり外したりしたいのです。 逆にアイスクリームにチェックを入れたらソフトクリームにチェックが入ったり外したりもしたいです。 また、可能であれば下記に記載するMacro1とMacro2を簡略化する方法があればご教授ください。 セルがTrueになったらリンクしてるセルのArray変数を判別+Macro1のgroup1を自動的に切り替わるようにしたいです。 コードは ----- Sub Macro0() Dim group1 As Variant Dim group2 As Variant Dim group3 As Variant Dim group4 As Variant Dim group5 As Variant Dim grofile As Variant group1 = Array("・アイスクリーム", "・ソフトクリーム") group2 = Array("・ホットケーキ") group3 = Array("・ショートケーキ") group4 = Array("・プリン") group5 = Array("・クレープ") grofile = 0 Macro1 Macro2 End Sub ----- Private Sub Macro1() If grofile = Filter(group1, Cells(2, "A")) And Cells(2, "D") = True Then If grofile = Filter(group1, Cells(2, "A")) Then Cells(2, "D") = True If grofile = Filter(group1, Cells(3, "A")) Then Cells(3, "D") = True If grofile = Filter(group1, Cells(4, "A")) Then Cells(4, "D") = True If grofile = Filter(group1, Cells(2, "B")) Then Cells(2, "E") = True If grofile = Filter(group1, Cells(3, "B")) Then Cells(3, "E") = True If grofile = Filter(group1, Cells(4, "B")) Then Cells(4, "E") = True ElseIf grofile = Filter(group1, Cells(2, "A")) And Cells(2, "D") = False Then If grofile = Filter(group1, Cells(2, "A")) Then Cells(2, "D") = False If grofile = Filter(group1, Cells(3, "A")) Then Cells(3, "D") = False If grofile = Filter(group1, Cells(4, "A")) Then Cells(4, "D") = False If grofile = Filter(group1, Cells(2, "B")) Then Cells(2, "E") = False If grofile = Filter(group1, Cells(3, "B")) Then Cells(3, "E") = False If grofile = Filter(group1, Cells(4, "B")) Then Cells(4, "E") = False End If End Sub ----- Private Sub Macro2() If grofile = Filter(group2, Cells(2, "A")) And Cells(2, "D") = True Then If grofile = Filter(group2, Cells(2, "A")) Then Cells(2, "D") = True If grofile = Filter(group2, Cells(3, "A")) Then Cells(3, "D") = True If grofile = Filter(group2, Cells(4, "A")) Then Cells(4, "D") = True If grofile = Filter(group2, Cells(2, "B")) Then Cells(2, "E") = True If grofile = Filter(group2, Cells(3, "B")) Then Cells(3, "E") = True If grofile = Filter(group2, Cells(4, "B")) Then Cells(4, "E") = True ElseIf grofile = Filter(group2, Cells(2, "A")) And Cells(2, "D") = False Then If grofile = Filter(group2, Cells(2, "A")) Then Cells(2, "D") = False If grofile = Filter(group2, Cells(3, "A")) Then Cells(3, "D") = False If grofile = Filter(group2, Cells(4, "A")) Then Cells(4, "D") = False If grofile = Filter(group2, Cells(2, "B")) Then Cells(2, "E") = False If grofile = Filter(group2, Cells(3, "B")) Then Cells(3, "E") = False If grofile = Filter(group2, Cells(4, "B")) Then Cells(4, "E") = False End If End Sub ----- Macro1の2行目 If grofile = Filter(group1, Cells(2, "A")) And Cells(2, "D") = True Then で先ほども書きましたが「型が一致しません」と表示されます。 If文の記述方法かFilterの使い方を間違えていると思うのですがどう直したらいいかわからない状況です。 元々のコードは ・Arrayに複数の値が入っている ・グループとグループ内のアイテムはさらに多い ・「プロシージャが大きすぎます」と表示されたためマクロを呼び出すように変更 ・そのため呼び出すマクロが多い ・Macro1とMacro2のようなコードが更に35個近くある ・このようなコードになっている理由は今後も変数の値とグループを更新する必要があるため となっています。 説明がわかりづらいですが宜しくお願い致します。 < 使用 Excel:Excel2010、使用 OS:Windows7 > ---- Filterで配列に含まれる文字列の個数を取得しようとしているようですが、 そこがまず違います 型が一致しません というのは、 grofileが数値、Filter以下が配列なので比較できないという意味です Filter は 配列を返しますので 添え字をつけてあげないと値は取得できません 下記のコードを実行してみてください Sub test1() Dim a As Variant a = Filter(Array("A", "B", "C"), "B") MsgBox a 'エラーになります MsgBox a(0) 'エラーになりません End Sub Filter の結果で、判断したいなら 以下のコードで動作確認してみてください Sub test2() If UBound(Filter(Array("A", "B", "C"), "D")) = -1 Then MsgBox "配列中に指定した文字列はありません" Else MsgBox "配列中に指定した文字列はあります" End If If UBound(Filter(Array("A", "B", "C"), "B")) = -1 Then MsgBox "配列中に指定した文字列はありません" Else MsgBox "配列中に指定した文字列はあります" End If End Sub (渡辺ひかる) 2019/07/25(木) 09:07 ...
https://www.excel.studio-kazu.jp/wiki/kazuwiki/201907/20190725045345.txt - [detail] - similar
PREV NEXT
Powered by Hyper Estraier 1.4.13, with 97065 documents and 608342 words.

訪問者:カウンタValid HTML 4.01 Transitional