By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

wildcard searches

P: n/a
I'm currently tearing my hair out on this one. I'm trying to run
through a bunch of worksheets in a bunch of workbooks and only run an
import on the ones that match the type of name I'm looking for.

I thought it would be a simple matter of:

sheetRange = xlSheet.Name

If sheetRange = "AOD*" Then

Do
--
--
--

So what happens if I print out the sheetrange is it says AODblahblah
but will not go into the if statment, is this not a wildcard? I have
declared sheetrange to be both a variant and a string but it doesn't
seem to make any difference.

Any help would be much appreciated, surely it can't really be as hard
as I'm making it?

Thanks

Jul 10 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try changing you statement to LIKE rather than =

If xlSheet.Name equals AODblahblah, it doesn't equal AOD*, it is like AOD*

IF SheetRange like "AOD*" then......

Mark

<ma****************@lmco.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
I'm currently tearing my hair out on this one. I'm trying to run
through a bunch of worksheets in a bunch of workbooks and only run an
import on the ones that match the type of name I'm looking for.

I thought it would be a simple matter of:

sheetRange = xlSheet.Name

If sheetRange = "AOD*" Then

Do
--
--
--

So what happens if I print out the sheetrange is it says AODblahblah
but will not go into the if statment, is this not a wildcard? I have
declared sheetrange to be both a variant and a string but it doesn't
seem to make any difference.

Any help would be much appreciated, surely it can't really be as hard
as I'm making it?

Thanks

Jul 10 '06 #2

P: n/a
ma****************@lmco.com wrote:
I'm currently tearing my hair out on this one. I'm trying to run
through a bunch of worksheets in a bunch of workbooks and only run an
import on the ones that match the type of name I'm looking for.

I thought it would be a simple matter of:

sheetRange = xlSheet.Name

If sheetRange = "AOD*" Then

Do
--
--
--

So what happens if I print out the sheetrange is it says AODblahblah
but will not go into the if statment, is this not a wildcard? I have
declared sheetrange to be both a variant and a string but it doesn't
seem to make any difference.

Any help would be much appreciated, surely it can't really be as hard
as I'm making it?

Thanks
If AOD is a constant value then
If Left(sheetrange,3) = "AOD" then

If it is a variable then...
Dim strName As String
strName = "AOD"
If Left(sheetrange,len(strName)) = strName then
Jul 10 '06 #3

P: n/a
Hi Madeleine,

Tried: IF (InStr(1,sheetRange,"AOD") 0 ) then ...?

HBInc.
ma****************@lmco.com wrote:
I'm currently tearing my hair out on this one. I'm trying to run
through a bunch of worksheets in a bunch of workbooks and only run an
import on the ones that match the type of name I'm looking for.

I thought it would be a simple matter of:

sheetRange = xlSheet.Name

If sheetRange = "AOD*" Then

Do
--
--
--

So what happens if I print out the sheetrange is it says AODblahblah
but will not go into the if statment, is this not a wildcard? I have
declared sheetrange to be both a variant and a string but it doesn't
seem to make any difference.

Any help would be much appreciated, surely it can't really be as hard
as I'm making it?

Thanks
Jul 11 '06 #4

P: n/a
That was perfect thanks very much, worked a charm.

Mark Reed wrote:
Try changing you statement to LIKE rather than =

If xlSheet.Name equals AODblahblah, it doesn't equal AOD*, it is like AOD*

IF SheetRange like "AOD*" then......

Mark

<ma****************@lmco.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
I'm currently tearing my hair out on this one. I'm trying to run
through a bunch of worksheets in a bunch of workbooks and only run an
import on the ones that match the type of name I'm looking for.

I thought it would be a simple matter of:

sheetRange = xlSheet.Name

If sheetRange = "AOD*" Then

Do
--
--
--

So what happens if I print out the sheetrange is it says AODblahblah
but will not go into the if statment, is this not a wildcard? I have
declared sheetrange to be both a variant and a string but it doesn't
seem to make any difference.

Any help would be much appreciated, surely it can't really be as hard
as I'm making it?

Thanks
Jul 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.