Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Adelisa Fischer   on Sep 01 In MS Office Category.

  
Question Answered By: Chad Bradley   on Sep 01

Thanks for the information. I thought that I should only declare  it in one
place because I expected that if I declared it in more than one place it
would cause confusion and we both agree there.



I have the variables  in the top of the module  and declare them as "Public"
after the top line of "Option Explicit". I always tend to use "Option
Explicit" because it is so easy to misspell variable  names or create new
ones when it is not intended to do so. I have done that many times in the
past, before I found and used the Option Explicit command, and created  many
problems that I had a hard time  finding.



I did find one logic problem  in the program  and that was with the variable
ResponseQPI. I found that I either set  it as VbYes or never set it at all
in one area of the program. I skipped over the section where I set it as
VbNo and therefore had a problem if I tried to use it later. One of the
times I used the program and it failed at the point of using that particular
variable I noted that the value of the variable was neither yes or no but
just blank. That was when I started looking for the logic error in a
different manor and finally found a problem.



I have never heard of the dot notation, but I will keep that in mind as I
have to continually change this program for various reasons.



One additional point you brought up, you say that ".they will retain  their
values during execution of the VBA program. However, they are not saved -
they are simply Global Variables". Does this mean that you set a variable
value Globally and place a value in it. If you go back to the spreadsheet
and do a series  of other operations and then restart more procedures the
values you placed in the variables are lost unless you reset  them again? I
have found this to be the case  for some things and have to constantly rerun
a particular procedure to reset variables that I used before. I don't
always have to do this, but I have found that some of the variables lose
their values.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Public variables Or get search suggestion and latest updates.


Tagged: