プロが教える店舗&オフィスのセキュリティ対策術

Vba に関して質問です。

Dim a1,a2 a3, as integer

Dim b as integer
Dim c as integer
c= 22
b = b+1
c= c+1

a = "a"& (b)
a = sheets("出力").cells(c,3).value

Loop

If a1=selection.value or a2=selection.value or a3= selection.value then
activecell =1
End if

ややこしい書き方で申し訳ございません。
a1 = sheets("出力").cells(23,3).value
a2 = sheets("出力").cells(24,3).value
a3 = sheets("出力").cells(25,3).value
では反応するですが、上記の書き方では判定してくれません。
現在アクティブシートとある数値とシート2(出力)
を判定するのにどうもうまくいきません。
知識人の方お力お貸しくださいよろしくお願いします

A 回答 (2件)

もしかしたら配列変数を使いたかったのでしょうか?


それでしたら以下のような感じではないでしょうか?
-----------------------------------------------------------------------------
Sub test()
Dim a(3) As Integer
Dim b As Integer
Dim c As Integer
c = 22
Do While b < 3
b = b + 1
c = c + 1
a(b) = Sheets("出力").Cells(c, 3).Value
Loop
If a(1) = Selection.Value Or a(2) = Selection.Value Or a(3) = Selection.Value Then
ActiveCell = 1
End If
End Sub
-----------------------------------------------------------------------------
    • good
    • 0

「Do …」が無いような気がしますが

    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!