I want to update a single (1 of 3) variable in a Sub
.
The 3 variables have already been assigned, but I would like to update one of the variables.
See script below for a simple example of passing string
s between subs in different Macros
In Macro1
Sub Sub1()
Text1 = "First Text"
Text2 = "Second Text"
Text3 = "Third Text"
Call Macro2.Sub2(Text1, Text2, Text3)
End Sub
In Macro2
Public PassedText1, PassedText2, PassedText3 As String
Sub Sub2(ByVal r1 As String, ByVal r2 As String, ByVal r3 As String)
PassedText1 = r1
PassedText2 = r2
PassedText3 = r3
End Sub
'=======================
I know I can create another sub in Macro2
where I can then pass a string
and then assign it to the Public variable.
If there not another way?
I though of Something like:
Sub Sub3()
SomeText = "New Text"
Call Sub2(r1:=SomeText)
End Sub
If you define your sub like this, you can use what you proposed :
So, 2 changed things for each argument
Optional ByVal r1 As Variant
:Optional
speaks for itselfAs Variant
because you'll need to test is the argument is present in your call with theIsMissing()
method, but for that the argument need to be defined as a VariantSo like this for the 3 arguments in your proc :