ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable value (https://www.excelbanter.com/excel-programming/405825-variable-value.html)

sonu[_2_]

Variable value
 
Hi,

I want to creat a combo box that remembers what value is selected
when it was used the last time.

For example I want to create a comb box where you can select column A
thru Z. If the uses selects column B the first time he used the
application I want this combo box to show this value when next time
the application is started again.

Is there a type of variable I can use for this or I have to save the
value somewhere and just read it from there the next time.

Please let me know if there is a better way of doing this.

Thanks
Sonu

Ronald R. Dodge, Jr.[_2_]

Variable value
 
The value can only be stored within a worksheet under this situation as
variables within VBA are only declared and instantiated when they are
brought into scope and adjusted as needed (Except for constants as constant
variables by it's very nature can't be changed). The only exception to that
rule, but would not work in this case are veriables known as Constants. The
reason why a Constant variable isn't going to work, the value the constant
variable hold is hard coded within VBA at declaration time. All other
variables are instantiated to a default value at the time they are declared
and brought into scope. For this sort of reason, you setup your variables
as:

Declare type of variable (what data type) at the appropriate level (Global,
Module, or Method level).
A method is either a subprocedure (Sub) or function (Function).
Set/Let the variable be of a certain Object/Value respectively (Done within
a method in most cases, but can also be done within the signiture portion of
a method, which a signature is the declaration of variable(s) in between the
paranthesises after the method name).

I'm not sure how much you know of programming, but you can use range names
in the event that you think insertion/deletion of rows/columns/cells may
take place as VBA doesn't adjust range references to easily, which I been
able to account for this only via the usage of range names.

Sincerely,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"sonu" wrote in message
...
Hi,

I want to creat a combo box that remembers what value is selected
when it was used the last time.

For example I want to create a comb box where you can select column A
thru Z. If the uses selects column B the first time he used the
application I want this combo box to show this value when next time
the application is started again.

Is there a type of variable I can use for this or I have to save the
value somewhere and just read it from there the next time.

Please let me know if there is a better way of doing this.

Thanks
Sonu




-goss

Variable value
 
On Feb 8, 12:48 pm, sonu wrote:
Hi,

I want to creat a combo box that remembers what value is selected
when it was used the last time.

For example I want to create a comb box where you can select column A
thru Z. If the uses selects column B the first time he used the
application I want this combo box to show this value when next time
the application is started again.

Is there a type of variable I can use for this or I have to save the
value somewhere and just read it from there the next time.

Please let me know if there is a better way of doing this.

Thanks
Sonu


Hi Sonu,

Store the selected value on a sheet and read the value into memory the
next time the workbook is opened

Regards
-goss

Dave Peterson

Variable value
 
Is this a combobox from the control toolbox that's been placed on a worksheet?

If yes, how about using a linkedcell (on a hidden worksheet???).

If the workbook is saved after the choice, it should be remembered the next time
the workbook opens.

sonu wrote:

Hi,

I want to creat a combo box that remembers what value is selected
when it was used the last time.

For example I want to create a comb box where you can select column A
thru Z. If the uses selects column B the first time he used the
application I want this combo box to show this value when next time
the application is started again.

Is there a type of variable I can use for this or I have to save the
value somewhere and just read it from there the next time.

Please let me know if there is a better way of doing this.

Thanks
Sonu


--

Dave Peterson


All times are GMT +1. The time now is 05:35 PM.

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