Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • 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 LissRetired ProgrammerCommented:
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 LissRetired ProgrammerCommented:
What the Author means is that somewhere in the code he has something like

MyArray(2) = "Dog"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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