View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Newbie General Programming ??

No problem.
It wasn't a criticism - just a caution that a general answer might not be
true in a specific situation - so if you had a specific situation in mind,
blah blah :-)

--
Regards,
Tom Ogilvy

"Bill Case" wrote in message
...
Thanks Tom;

Yes , that was the kind of gerneral answer I was looking for. You may
rember in one of my previous posts that I had some beginners general
programming questions. You suggested I could ask on this list. So I just
did. That question was one of them.

Regards Bill

"Tom Ogilvy" wrote:

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