Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dennis
 
Posts: n/a
Default 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   Report Post  
Chip Pearson
 
Posts: n/a
Default

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   Report Post  
Dennis
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
I Need VBA Assistance for global variable question Brent E Excel Discussion (Misc queries) 1 March 1st 05 08:46 PM
Can I use a variable to call up another sheet in Excel? GD Cooley Excel Worksheet Functions 1 February 13th 05 05:40 AM
Can I use a variable to call up another sheet in Excel? GD Cooley Excel Worksheet Functions 0 February 11th 05 02:47 PM
change function variable prompts?? thinkingfield Excel Worksheet Functions 1 November 8th 04 04:01 PM


All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"