Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

why doesn't this conditional wok?

sheet names are sheettest,save,sheettest2.
MyArray(2) is Dog
set two watches to make sure that is what is being seen.
fig is set to false
fig becomes true even though it never finds a sheet called Dog.
can someone see why????????

For Each WS In Worksheets
If WS.Name Like MyArray(2) Then flg = True: Exit For
Next
If flg = True Then
   DirectCopyInfo = True
   'do nothing
Else
   Sheets.Add.Name = MyArray(2)
   DirectCopyInfo = False
End If
0
javagair
Asked:
javagair
  • 2
  • 2
  • 2
  • +2
1 Solution
 
Martin LissOlder than dirtCommented:
What are all your worksheet names? And why do you use 'Like' rather than '='?

This article of mine may help you. It's aimed at VB6 but most of it allies to VBA.
0
 
gowflowCommented:
what do you meant by:
MyArray(2) is Dog

how does it translate in VBA ??? all the rest is fine. The only hick-up is
MyArray(2) is Dog
This is un heared of for me so far !!!
gowflow
0
 
Martin LissOlder than dirtCommented:
What the Author means is that somewhere in the code he has something like

MyArray(2) = "Dog"
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
redmondbCommented:
Hi, javagair.

Please add the following line...
Debug.Print myarray(2) & " - " & ws.Name & " - " & flg
...after....
For Each ws In Worksheets
... and let us know what's output to the Immediate Pane.

Thanks,
Brian.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you write "fig" but in the code you write "flg"
please make sure it's not a plain "typo" ...
0
 
gowflowCommented:
I don't see hjow your Flg goes to True
check out this file make sure macroes are set to enabled

noted also as angelIII pointed out the fig and flg maybe a typo in your code setting already fig to True whyle ur looking for flg ??
gowflow
test.xls
0
 
javagairAuthor Commented:
copy don't type is the rule
l and i are not interchangeable except to us blind guys

gary
0
 
redmondbCommented:
Thanks, Gary.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now