- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
Sub Макрос2()
Dim pos0, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9, digitPos As Integer
For Counter = 2 To 999999
digitPos = 1000
Set curCell = Worksheets("Лист1").Cells(Counter, 5)
Set primCell = Worksheets("Лист1").Cells(Counter, 6)
pos0 = InStr(1, primCell.Value, "0")
pos1 = InStr(1, primCell.Value, "1")
pos2 = InStr(1, primCell.Value, "2")
pos3 = InStr(1, primCell.Value, "3")
pos4 = InStr(1, primCell.Value, "4")
pos5 = InStr(1, primCell.Value, "5")
pos6 = InStr(1, primCell.Value, "6")
pos7 = InStr(1, primCell.Value, "7")
pos8 = InStr(1, primCell.Value, "8")
pos9 = InStr(1, primCell.Value, "9")
If pos0 > 0 And pos0 < digitPos Then
digitPos = pos0
End If
If pos1 > 0 And pos1 < digitPos Then
digitPos = pos1
End If
If pos2 > 0 And pos2 < digitPos Then
digitPos = pos2
End If
If pos3 > 0 And pos3 < digitPos Then
digitPos = pos3
End If
If pos4 > 0 And pos4 < digitPos Then
digitPos = pos4
End If
If pos5 > 0 And pos5 < digitPos Then
digitPos = pos5
End If
If pos6 > 0 And pos6 < digitPos Then
digitPos = pos6
End If
If pos7 > 0 And pos7 < digitPos Then
digitPos = pos7
End If
If pos8 > 0 And pos8 < digitPos Then
digitPos = pos8
End If
If pos9 > 0 And pos9 < digitPos Then
digitPos = pos9
End If
'MsgBox Left(primCell.Value, digitPos - 1)
curCell.Value = Trim(Left(primCell.Value, digitPos - 1))
Next Counter
End Sub