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 |
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 |
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 |
All times are GMT +1. The time now is 04:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com