Home |
Search |
Today's Posts |
#1
|
|||
|
|||
How to keep a Variable alive after a Call to Sub Routine
XL 2003
Placed Public TextVar As Variant at beginning of Module Dim TextVar as Variant (in 1st proceedure) Then Dim TextVar as Variant (in 2nd proceedure) Then Dim TextVar as Variant (in both proceedures) "TextVar" is is set with 400+ Text characters and carries that value until the "End Sub" of the 2nd procedure. When I attempt to use TextVar in the 1st Procedure, its value is "Empty" Yes, I know about the 255 limit for Strings is it also true for Variants? Is that limit blowing my variable? If so, is there a workaround? Thanks, Dennis |
#2
|
|||
|
|||
Don't use the same name of global and local variables.
-- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Dennis" wrote in message ... XL 2003 Placed Public TextVar As Variant at beginning of Module Dim TextVar as Variant (in 1st proceedure) Then Dim TextVar as Variant (in 2nd proceedure) Then Dim TextVar as Variant (in both proceedures) "TextVar" is is set with 400+ Text characters and carries that value until the "End Sub" of the 2nd procedure. When I attempt to use TextVar in the 1st Procedure, its value is "Empty" Yes, I know about the 255 limit for Strings is it also true for Variants? Is that limit blowing my variable? If so, is there a workaround? Thanks, Dennis |
#3
|
|||
|
|||
Thanks Chip
I attempted Static TextVar As Variant in either and both procedures but TextVar was still "Empty". What ultimately worked was: Dim TextVar As Variant (Placed outside of both procedures) Dennis "Chip Pearson" wrote: Don't use the same name of global and local variables. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Dennis" wrote in message ... XL 2003 Placed Public TextVar As Variant at beginning of Module Dim TextVar as Variant (in 1st proceedure) Then Dim TextVar as Variant (in 2nd proceedure) Then Dim TextVar as Variant (in both proceedures) "TextVar" is is set with 400+ Text characters and carries that value until the "End Sub" of the 2nd procedure. When I attempt to use TextVar in the 1st Procedure, its value is "Empty" Yes, I know about the 255 limit for Strings is it also true for Variants? Is that limit blowing my variable? If so, is there a workaround? Thanks, Dennis |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
I Need VBA Assistance for global variable question | Excel Discussion (Misc queries) | |||
Can I use a variable to call up another sheet in Excel? | Excel Worksheet Functions | |||
Can I use a variable to call up another sheet in Excel? | Excel Worksheet Functions | |||
change function variable prompts?? | Excel Worksheet Functions |