Newbie General Programming ??
specifics would be better, but in general, if you don't care what the current
condition is and you want the situation to be a specific condition
regardless, there is no reason to check.
Range("a1:B6").name = "MyName"
will create MyName if it didn't exist and redefine it if it did as an
example.
Another example. If I want to put a file in a subdirectory, if I know the
the higher level directory is there (C:\Data in the example), I can do
' ignore the error if it already exists
On error resume next
mkdir "C:\Data\Subdir"
On error goto 0
Activeworkbook.SaveAs "C:\Data\Subdir\MyFile.xls"
You then don't have to check if SubDir exists before doing this.
--
Regards,
Tom Ogilvy
"Bill Case" wrote:
Hi; Just Wondering;
Does it really make a difference if you don't test for a previous condition
before making a change to a format etc. in VBA? For example, will I hurt
anything or endager anything if I just do:
'Make condition = True' no matter if the existing condition has already been
met, rather than:
'If condition = False Then make condition = True'
It seems sometimes I spend a lot of coding time look for the state of
conditions when I really don't care. I just want everything to be the same.
Regards Bill
|