Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to identify worksheets by part of name?

Status
Not open for further replies.

makeitwork09

Technical User
Sep 28, 2009
170
US
I have a workbook where it is not certain what order the worksheets will be
each month. The naming convention for the first 11 characters for each
worksheet will be the same each month, however, the remaining characters
can change.

Based on the name of the worksheet, the first 11 characters of worksheet, in this case, certain routines need to be performed. The worksheet starting with 123ABC-F456 must always have something done to it before the appropriate routines are done to the second worksheet, which starts with 123ABC-Stan each month. That being the case how would I:

(1) identify the worksheet starting with 123ABC-F456 and then correctly reference it to add formulas to it?
(2) identify the other worksheet starting with 123ABC-Stan after completing the steps in 123ABC-F456 and correctly reference it in the code to add formulas to it?

Thanks
 


Hi,
Code:
dim ws as worksheet

for each ws in worksheets
  with ws
     select case left(.name) 
        case "123ABC-F456"
          'do stuff for 123ABC-F456
        case "123ABC-Stan"
          'do stuff for 123ABC-Stan
     end select
  end with
next





Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


oops I missed the SECOND LEFT argument
Code:
select case left(.name[b],11[/b])

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top