Live-Forum - Die aktuellen Beiträge
Datum
Titel
17.04.2024 18:57:33
17.04.2024 16:56:58
Anzeige
Archiv - Navigation
1552to1556
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Instringsuche

Instringsuche
20.04.2017 20:04:19
heinzs
Hallo Wissende :)!
ich habe einen langen Text z.B. in Zelle A1:
abcdefghijklmnopqrstuvwxyz#1147abcdefghijk#1155xs
Frage:
Wenn in der Zelle #11xx vorkommt soll nur dieser Teil (also #1147 und #1155) rot fett formatiert werden (xx steht für beliebige Ziffern und nicht für Buchstaben)
Hat jemand eine Idee?
Danke für Hilfe!
MfG
Heinz

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Instringsuche
20.04.2017 20:23:56
CitizenX
Hi,
BSP:
Option Explicit
Sub test()
Dim str$, regex As Object, omatch As Object, i
Set regex = CreateObject("vbscript.regexp")
str = [A1].Text
With regex
.Pattern = "#11\d{2}"
.Global = True
If .test(str) Then
Set omatch = .Execute(str)
For i = 0 To omatch.Count - 1
With [A1].Characters(Start:=omatch.Item(i).firstindex, Length:=omatch.Item(i). _
Length).Font
.FontStyle = "Fett"
.Color = -16776961
End With
Next
End If
End With
End Sub
VG
Steffen
AW: Instringsuche
20.04.2017 20:29:40
Nepumuk
Hallo Heinz,
teste mal:
Option Explicit

Public Sub Start()
    
    Dim objRegEx As Object, objMatch As Object
    Dim objCell As Range
    Dim lngIndex As Long
    
    Application.ScreenUpdating = False
    
    Set objRegEx = CreateObject("VBScript.RegExp")
    
    With objRegEx
        .Global = True
        .Pattern = "#11\d{2}"
    End With
    
    For Each objCell In Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
        
        Set objMatch = objRegEx.Execute(objCell.Value)
        
        With objMatch
            
            For lngIndex = 0 To .Count - 1
                
                With objCell.Characters(Start:=.Item(lngIndex).FirstIndex + 1, Length:=5).Font
                    
                    .Bold = True
                    .Color = vbRed
                    
                End With
            Next
        End With
    Next
    
    Application.ScreenUpdating = True
    
    Set objMatch = Nothing
    Set objRegEx = Nothing
    
End Sub

Gruß
Nepumuk
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige