Avatar of javagair
javagairFlag for United States of America

asked on 

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
Microsoft Excel

Avatar of undefined
Last Comment
redmondb
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

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.
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
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

What the Author means is that somewhere in the code he has something like

MyArray(2) = "Dog"
ASKER CERTIFIED SOLUTION
Avatar of redmondb
redmondb
Flag of Afghanistan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
you write "fig" but in the code you write "flg"
please make sure it's not a plain "typo" ...
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
Avatar of javagair
javagair
Flag of United States of America image

ASKER

copy don't type is the rule
l and i are not interchangeable except to us blind guys

gary
Avatar of redmondb
redmondb
Flag of Afghanistan image

Thanks, Gary.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo