ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing a variable from sheet code to a module (https://www.excelbanter.com/excel-programming/442158-passing-variable-sheet-code-module.html)

Robert Pearson[_2_]

Passing a variable from sheet code to a module
 
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.

Gary Brown[_6_]

Passing a variable from sheet code to a module
 
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
--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Robert Pearson" wrote:

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.


Jim Cone[_2_]

Passing a variable from sheet code to a module
 
'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
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.


All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com