Passing a variable from sheet code to a module

R

Robert Pearson

Is it possible to pass a variable from a worksheet_calculate macro to a macro
in a module?

I'm familiar with public variables and calling functions, but these don't
enable me to do what I need.
 
G

Gary Brown

Put a variable declaration as public before the first procedure in a standard
VBA module (NOT a worksheet module OR a form module).
Ex: PUBLIC varTest as variant
This variable is now available to ALL MODULEs including worksheet modules
 
J

Jim Cone

'Sheet Module...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Sludge As Double
Sludge = Me.Range("A1").Value
Call MacroInModule(Sludge)
End Sub

'Standard/General Module...
Sub MacroInModule(ByRef PassedValue As Double)
'do something using PassedValue
End Sub
--
Jim Cone
Portland, Oregon USA




"Robert Pearson" <Robert (e-mail address removed)>
wrote in message Is it possible to pass a variable from a worksheet_calculate macro to a macro
in a module?

I'm familiar with public variables and calling functions, but these don't
enable me to do what I need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top