PDA

View Full Version : [SOLVED:] Use the same Variable in the module



Romulo Avila
04-12-2020, 09:39 AM
Good afternoon,


I am in need of help, I have an event "BeforeDoubleClick" as below



Option Explicit
Public Line As Integer


Private Sub Worksheet_BeforeDoubleClick (ByVal Target As Range, Cancel As Boolean)


If Not Intersect ([B2: B10], Target) Is Nothing Then Target.Value = IIf (Target.Value = "", "ok", "")
Line = Target.Row
Call call
Cancel = True
End Sub


Where do I need to use the value of the variable within a module (I did this example)



Sub test ()
MsgBox Line
End Sub


Only when it goes to the Module the variable is empty, how can I solve it.


Thank you

RomuloRDM

Paul_Hossler
04-12-2020, 10:12 AM
In the WS module



Option Explicit


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect([B2: B10], Target) Is Nothing Then Target.Value = IIf(Target.Value = "", "ok", "")

Line = Target.Row
test
Cancel = True
End Sub





In a standard module



Option Explicit


Public Line As Integer


Sub test()
MsgBox Line
End Sub

Romulo Avila
04-12-2020, 10:24 AM
Paul,
Good afternoon,


Thank you very much, it worked.