Sub Сопоставл_ТТ()
On Error Resume Next
Application.ScreenUpdating = False
Dim A As Long, B As String, C As String, D As Long, E As String
Dim C1 As String, C2 As String, C3 As String, C4 As String
Dim TTV As String
Dim C11 As Long, C21 As Long, C31 As Long
Dim f As Long, g As Integer, i As Long, h As Long
Dim k As Long, k1 As Long
Dim M As Long
Dim q As Range
Dim TTL As Long
Dim KL
M = 3
k1 = ActiveCell.Row
f = ActiveCell.Column
A = WorksheetFunction.Match("Источник, присоединение", Range(Cells(1, 1), Cells(1, 40)), 0)
For k = k1 To k1 + M
TTL = 0
If Cells(k, f) <> 0 And WorksheetFunction.Search("РУ", Cells(k, f - (f - A + 1))) Then
Cells(k, f) = Cells(k, f)
Else
'f = ActiveCell.Column
'If k = 0 Then g = ActiveCell.Row Else g = ActiveCell.Row + 1
'If Cells(g, f) = 0 Then
Set q = Cells(k, f - (f - A + 1))
C1 = Left(q.Value, WorksheetFunction.Search("--", q.Value) - 1)
C11 = Len(C1)
prov = WorksheetFunction.Search("--", q, _
WorksheetFunction.Search("--", q) + 1)
C2 = Mid(q, C11 + 3, WorksheetFunction.Search("--", q, _
WorksheetFunction.Search("--", q) + 1) - WorksheetFunction.Search("--", q) - 2)
C21 = Len(C2)
C31 = Len(q) - C21 - C11 - 4
C3 = Mid(q, C11 + C21 + 5, C31)
C = Left(C3, 5)
If Left(C, 4) = "МВ-6" Or Left(C, 4) = "ВВ-6" Or _
Left(C, 5) = "СВВ-6" Or Left(C, 5) = "СМВ-6" Then
B = "ТТ-6кВ"
D = WorksheetFunction.Search(" ", C3, WorksheetFunction.Search _
(" ", C3) + 1)
' KL = WorksheetFunction.Search("яч", C3)
If D > 0 Then _
C4 = Mid(C3, WorksheetFunction.Search("яч", C3) + 4, WorksheetFunction.Search(" ", _
C3, WorksheetFunction.Search("яч", C3)) - WorksheetFunction.Search("яч", C3) - 4) _
Else C4 = Mid(C3, WorksheetFunction.Search("яч", C3) + 4, Len(C3) - _
WorksheetFunction.Search("яч", C3) - 3)
TTV = C1 & "--" & C2 & "--ТТ-6кВ яч.№" & C4
TTL = WorksheetFunction.Match(TTV, Range(Cells(1, f - (f - A + 1)), _
Cells(4300, f - (f - A + 1))), 0)
If D > 0 Then E = Left(B, D - 1) Else E = B
Cells(k, ActiveCell.Column) = WorksheetFunction.Max _
(Range(Cells(16, f), Cells(k1 + M, f))) + 1
Cells(TTL, f) = Cells(k, f)
Cells(k, f).Interior.Color = vbGreen
Cells(TTL, f).Interior.Color = vbGreen
Else
Cells(k, f) = Cells(k, f)
End If
End If
Application.StatusBar = "выполнено " & Round(k * 100 / M, 0) & " %"
Next
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub |