Hi guys,

now I need to find specific data in sheet name
all sheets name in the workbook are on the same pattern.
Here is the patern: "XXX YYY ZZZ"

All X, Y and Z are variable in lenght and they are seperate with a space.

I need the value of Z but how to find it with a variable lenght????

Thanks

Here is my code with where I need to introduce de tricky "last part of the sheet name"




VB Code:
  1. With Workbooks(lcFileName)
  2.             For lnSheetId = 2 To .Sheets.Count
  3.             ' sheet 1 is Dept... now starting from sheet 2 check if it is Ss-Dept
  4.                 If Not IsNumeric(.Sheets(lnSheetId).Name) And Len(Trim(.Sheets(lnSheetId).Name)) > 3 Then
  5.                     SsDept = .Sheets(lnSheetId).Name
  6.  
  7.                     'Need to find the specific data HERE
  8.                     'Need to find the specific data HERE
  9.  
  10.  
  11.                     SsDeptIndex = Workbooks(fullname).Sheets(tsNameFile & " " & SsDeptName).Index - 1 'marche pas
  12.                    
  13.                     'if sheet already exists in the Department Workbook
  14.                     If SheetExists(fullname, SsDept) = True Then
  15.                         Workbooks(fullname).Sheets(SsDept).Delete
  16.                     End If
  17.                     .Sheets(SsDept).Copy After:=Workbooks(fullname).Sheets(SsDeptIndex)
  18.                 End If
  19.             Next lnSheetId
  20.         End With