Informationen und Beispiele zum Thema MsgBox | |
---|---|
![]() |
MsgBox-Seite mit Beispielarbeitsmappe aufrufen |
Hallo,
ich möchte einen Bereich nach einer Zelle mit einem Unterstrich durchsuchen
Folgende Prozedur bringt jedoch nicht das gewünschte Ergebnis. Suche ich nach einem FontStyle funktioniert der Code jedoch, nicht jedoch für LineStyles.
In Excel selbst funktioniert die Suche, durch Application.FindFormat.Clear wird jedoch die Eingabe durch Excel gelöscht.
Sub FindLineStyle() Dim rg As Range Range("A4").Select Debug.Print "LineStyle before set = " & Range("A4").Borders(xlEdgeBottom).LineStyle Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous Debug.Print "LineStyle after set = " & Range("A4").Borders(xlEdgeBottom).LineStyle Application.FindFormat.Clear Range("A1:A9").Select Application.FindFormat.Borders(xlEdgeBottom).LineStyle = xlContinuous Set rg = Selection.Find(What:="", SearchFormat:=True) If Not rg Is Nothing Then Debug.Print rg.row Else Debug.Print "LineStyle after search = " & Range("A4").Borders(xlEdgeBottom).LineStyle End If Range("A4").Borders(xlEdgeBottom).LineStyle = xlLineStyleNone Debug.Print vbCrLf End Sub
With Application.FindFormat.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThick End With Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=True).Activate
Sub FormatSuchen() Dim rngZelle As Range With Application.FindFormat.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThick End With Set rngZelle = Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=True) MsgBox rngZelle.Address End Sub