The essence of the problem is as follows: there is an estimate that the program displays, the estimate contains the number of this estimate that looks like 00-00-0-00-00, this number is always in the same cell with the text and may look like 3 options: LOCAL ESTIMATE CALCULATION No. 00-00-0-00-00, or ESTIMATE CALCULATION No. 00-00-0-00-00, or LOCAL ESTIM No. 00-00-0-00-00. It is necessary to isolate the calculation number, call the List for them, then subtract the last 3 characters from the calculation number - this will be the Object number of the type (00-00-0-00), create a folder on the desktop under the object number and save the file with the name of the calculation number (00-00-0-00-00). The code below coped with this perfectly, until the text indicating the correction Kn of the type (00-00-0-00-00 Кn) was added to the number, where n is the correction number is always a one-digit number, i.e. maximum K9, and And - all the same thing only AND - change. I already broke my head how to implement it.
Sub xxx () Dim НомерОбъекта As String Dim НомерЛокального As String If Cells.Find(What:="СМЕТНЫЙ РАСЧЕТ № ", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) Is Nothing Then If MsgBox("Отсутствует фраза _СМЕТНЫЙ РАСЧЕТ №_. Макрос будет прерван!", vbCritical + vbOKOnly) = vbOK Then End Else End If Else НомерЛокального = Right(Cells.Find(What:="СМЕТНЫЙ РАСЧЕТ № ", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False), 13) Range("C1") = НомерЛокального НомерОбъекта = Mid(НомерЛокального, 1, 10) Range("C2") = НомерОбъекта ActiveSheet.Name = НомерЛокального folder = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & НомерОбъекта & "\" On Error Resume Next: MkDir folder ActiveWorkbook.SaveAs folder & НомерЛокального & ".xls" Application.CutCopyMode = False ' очищение буфера обмена End If End Sub