- ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:Excel VBA: private sub 内の変数の値を Sub へ渡すには)
Excel VBA: How to Pass the Value of a Variable Inside a Private Sub to a Sub
このQ&Aのポイント
- I am a beginner in VBA. How can I pass the value of a variable inside a private sub to a sub when it meets a certain condition? I think the variable inside the private sub can only be referenced within the private sub, but it doesn't work well. Is there a way to make it a global variable?
- To pass the value of a variable inside a private sub to a sub when it meets a certain condition in VBA, you can make use of global variables. The variable inside the private sub can only be referenced within the private sub, so making it a global variable allows other subs to access its value.
- In Excel VBA, you can pass the value of a variable inside a private sub to a sub when it meets a certain condition by making use of global variables. The variable inside the private sub is only accessible within the private sub, so declaring it as a global variable allows other subs to access its value.
- みんなの回答 (2)
- 専門家の回答
質問者が選んだベストアンサー
Sub Find_OK(var1) MsgBox "条件に合致したのは" & var1 & "です。" End Sub Private Sub Worksheet_Calculate() Dim var1 For var1 = 1 to 10 If var1 > 8 Then Call Find_OK(var1) End If Next End Sub
その他の回答 (1)
noname#97729
回答No.2
ちょと違うかもしれませんが このような感じでは、 Sub Find_OK(AAA As Integer) MsgBox "条件に合致したのは" & AAA & "です。" End Sub Sub Worksheet_Calculate() Dim var1 For var1 = 1 To 10 If var1 > 8 Then Find_OK (var1) Next End Sub
質問者
お礼
ありがとうございました。
お礼
ありがとうございました。うまくいきました。