AW: markiere bestimmte Strings
16.03.2009 00:08:08
Josef
Hallo Mehmet,
kein Prob lem.
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Sub colorTextBKN()
Dim rng As Range, rngF As Range
Dim intPos As Integer
With Range("C3:C100")
On Error Resume Next
Set rng = .SpecialCells(xlCellTypeConstants)
On Error GoTo 0
.Font.ColorIndex = xlAutomatic
.Font.Bold = False
End With
If Not rng Is Nothing Then
For Each rngF In rng
intPos = InStr(1, rngF.Text, "BKN")
Do While intPos > 0
If IsNumeric(Mid(rngF.Text, intPos + 3, 3)) Then
If Cint(Mid(rngF.Text, intPos + 3, 3)) < 3 Then
rngF.Characters(intPos, 6).Font.ColorIndex = 3
ElseIf Cint(Mid(rngF.Text, intPos + 3, 3)) < 6 Then
rngF.Characters(intPos, 6).Font.ColorIndex = 5
End If
End If
intPos = InStr(intPos + 1, rngF.Text, "BKN")
Loop
Next
End If
Set rng = Nothing
End Sub
Sub colorTextKT()
Dim rng As Range, rngF As Range
Dim intPos As Integer
With Range("C3:C100")
On Error Resume Next
Set rng = .SpecialCells(xlCellTypeConstants)
On Error GoTo 0
.Font.ColorIndex = xlAutomatic
.Font.Bold = False
End With
If Not rng Is Nothing Then
For Each rngF In rng
intPos = InStr(1, rngF.Text, "KT")
Do While intPos > 0
If IsNumeric(Mid(rngF.Text, intPos - 2, 2)) And Mid(rngF.Text, intPos - 6, 1) = " " Then
rngF.Characters(intPos - 5, 7).Font.Bold = True
If Cint(Mid(rngF.Text, intPos - 2, 2)) >= 20 And Cint(Mid(rngF.Text, intPos - 2, 2)) <= 30 Then
rngF.Characters(intPos - 2, 4).Font.ColorIndex = 5
ElseIf Cint(Mid(rngF.Text, intPos - 2, 2)) > 30 And Cint(Mid(rngF.Text, intPos - 2, 2)) <= 81 Then
rngF.Characters(intPos - 2, 4).Font.ColorIndex = 3
End If
End If
intPos = InStr(intPos + 1, rngF.Text, "KT")
Loop
Next
End If
Set rng = Nothing
End Sub
Gruß Sepp