Computing.Net > Forums > Office Software > Wildcards in VBA IF...THEN

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Wildcards in VBA IF...THEN

Reply to Message Icon

Name: clomper
Date: May 5, 2004 at 08:28:46 Pacific
OS: Winxph
CPU/Ram: 2.8/512
Comment:

Will someone PLEASE tell me how to use wildcards in VBA IF...THEN statements! Here's an example of what I'm trying to accomplish:

If ActiveSheet.Name <> "FORMMANAGER_EXPORT_XLS^*" Then
MsgBox "This sheet cannot be transferred."
End
End If

Obviously, this doesn't work, but you can see what I want. The sheet name will always begin with "FORMMANAGER_EXPORT_XLS", but it will have various different characters after that i.e. "FORMMANAGER_EXPORT_XLS1a047"

Thanks for helping an idiot :-)



Sponsored Link
Ads by Google

Response Number 1
Name: Jennifer SUMN
Date: May 5, 2004 at 11:05:04 Pacific
Reply:

Well, I don't know Visual Basic, but..

The If Then Else means..

If this condition is true
Then, do this
Else do that

So, that's the basis for your code. You need all three components, which you don't have in what you've posted...


0

Response Number 2
Name: Report_2
Date: May 6, 2004 at 04:07:03 Pacific
Reply:

Clomper,

There are a couple of folks here on this board that are more familiar with VBA but I see they must be on vacation.

If Jen's offering was not enough information then you may want to try posting at:
the OZGrid Excel/VBA forum board as they specialize in VBA and have helped me on several occaisions. They are quick too.

You do need to register for free before posting. It is harmless.

Regards,
Bryan


0

Response Number 3
Name: obarton3
Date: May 6, 2004 at 10:57:30 Pacific
Reply:

I'm assuming you have already written the necessary code that would trigger this routine. That said, try writting your routine like so:

If ActiveSheet.Name >= "FORMMANAGER_EXPORT_XLS" Then
MsgBox "This sheet cannot be transferred."
End If


Please note the > greater-than sign in front of the = equal sign. This eliminates the need for a wildcard character. Let me know if this works.

Davey


0

Response Number 4
Name: Jennifer SUMN
Date: May 9, 2004 at 05:01:47 Pacific
Reply:

Davey,

Where's your "ELSE?"


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Wildcards in VBA IF...THEN

MS Word if...then else wildcards www.computing.net/answers/office/ms-word-ifthen-else-wildcards/8825.html

Merge multiple wksht in Excel07 www.computing.net/answers/office/merge-multiple-wksht-in-excel07/6836.html

Combobox in Vba www.computing.net/answers/office/combobox-in-vba/8909.html