ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie, Variables not retained in sub? (https://www.excelbanter.com/excel-programming/353999-newbie-variables-not-retained-sub.html)

NT_eyeballs

Newbie, Variables not retained in sub?
 

Hey all,
Very new at teaching self VB in Excel.
Have created a simple loan repayment program (to learn with)
Got the basic 2 sheet code happening and am "prettying" it up.
Sheet 2 has a button to perform a Recalculate Option which works....BU
it doesn't retain the values within the sub??

Do I have to "pass parameters" to sub???
If so....how is that done?

NT

--
NT_eyeball
-----------------------------------------------------------------------
NT_eyeballs's Profile: http://www.excelforum.com/member.php...fo&userid=3180
View this thread: http://www.excelforum.com/showthread.php?threadid=51526


Gary''s Student

Newbie, Variables not retained in sub?
 
Just Dim the variables outside the sub.
--
Gary's Student


"NT_eyeballs" wrote:


Hey all,
Very new at teaching self VB in Excel.
Have created a simple loan repayment program (to learn with)
Got the basic 2 sheet code happening and am "prettying" it up.
Sheet 2 has a button to perform a Recalculate Option which works....BUT
it doesn't retain the values within the sub??

Do I have to "pass parameters" to sub???
If so....how is that done?

NT.


--
NT_eyeballs
------------------------------------------------------------------------
NT_eyeballs's Profile: http://www.excelforum.com/member.php...o&userid=31802
View this thread: http://www.excelforum.com/showthread...hreadid=515262



Bob Phillips[_6_]

Newbie, Variables not retained in sub?
 
or make it a Static variable.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Gary''s Student" wrote in message
...
Just Dim the variables outside the sub.
--
Gary's Student


"NT_eyeballs" wrote:


Hey all,
Very new at teaching self VB in Excel.
Have created a simple loan repayment program (to learn with)
Got the basic 2 sheet code happening and am "prettying" it up.
Sheet 2 has a button to perform a Recalculate Option which works....BUT
it doesn't retain the values within the sub??

Do I have to "pass parameters" to sub???
If so....how is that done?

NT.


--
NT_eyeballs
------------------------------------------------------------------------
NT_eyeballs's Profile:

http://www.excelforum.com/member.php...o&userid=31802
View this thread:

http://www.excelforum.com/showthread...hreadid=515262





NT_eyeballs[_2_]

Newbie, Variables not retained in sub?
 

Hey all,
Thnx for replies.

The variables Are dim'd in main. So I must be doing something wrong.
The variable is loaded via Inputbox initially, and in the re-calc sub I
am trying to allow the same variable to be re-loaded via another
inputbox, but display previous value as Default.
I have tried using a ghost variable (copy) as the default (in case
inputbox statement is clearing it) and that doesn't work either.

NT.


--
NT_eyeballs
------------------------------------------------------------------------
NT_eyeballs's Profile: http://www.excelforum.com/member.php...o&userid=31802
View this thread: http://www.excelforum.com/showthread...hreadid=515262



All times are GMT +1. The time now is 03:21 AM.

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