OVH Cloud OVH Cloud

VBA- recherche les cellules en gras

2 réponses
Avatar
twinley
Bonsoir,

Je crois que j'ai eu tous les N° d'erreurs... Alors si quelqu'un pouvait me
trouver la bonne syntaxe ?

Je cherche toutes les lignes qui sont en gras dans la colonne A1:A50 de la
feuille 5
Il n'aime pas : Set c = .FindFormat.Font.Bold

Sub findbold()
Range("A1").Select
With Worksheets(5).Range("a1:a50")
With Application.FindFormat.Font
Set c = .FindFormat.Font.Bold
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = True
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub

Merci pour l'aide
--
à+twinley

2 réponses

Avatar
michdenis
Bonjour

Voici une façon de sélectionner toutes les lignes qui ont au moins
une cellule en gras dans la plage A1:G50 de la feuille 1 ....

à toi d'adapter ...

'----------------------------------
Sub FindBold()

Dim Rg As Range, D As Range, R As Range
With Application.FindFormat.Font
.FontStyle = "Gras"
End With

With Worksheets("Feuil1")
For Each R In .Range("a1:g50").Rows
Set D = R.Find(What:="*", LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse, SearchFormat:=True)
If Not D Is Nothing Then
If Rg Is Nothing Then
Set Rg = R
Else
Set Rg = Union(Rg, R)
End If
End If
Next
End With
If Not Rg Is Nothing Then
Rg.Select
End If
End Sub
'----------------------------------


Salutations!



"twinley" <twinleym(at)hotmail.com> a écrit dans le message de news:
Bonsoir,

Je crois que j'ai eu tous les N° d'erreurs... Alors si quelqu'un pouvait me
trouver la bonne syntaxe ?

Je cherche toutes les lignes qui sont en gras dans la colonne A1:A50 de la
feuille 5
Il n'aime pas : Set c = .FindFormat.Font.Bold

Sub findbold()
Range("A1").Select
With Worksheets(5).Range("a1:a50")
With Application.FindFormat.Font
Set c = .FindFormat.Font.Bold
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = True
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub

Merci pour l'aide
--
à+twinley
Avatar
twinley
merci michdenis pour tes lumières
Bonne soirée
--
à+twinley
"michdenis" a écrit dans le message de
news:%
Bonjour

Voici une façon de sélectionner toutes les lignes qui ont au moins
une cellule en gras dans la plage A1:G50 de la feuille 1 ....

à toi d'adapter ...

'----------------------------------
Sub FindBold()

Dim Rg As Range, D As Range, R As Range
With Application.FindFormat.Font
.FontStyle = "Gras"
End With

With Worksheets("Feuil1")
For Each R In .Range("a1:g50").Rows
Set D = R.Find(What:="*", LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse, SearchFormat:=True)
If Not D Is Nothing Then
If Rg Is Nothing Then
Set Rg = R
Else
Set Rg = Union(Rg, R)
End If
End If
Next
End With
If Not Rg Is Nothing Then
Rg.Select
End If
End Sub
'----------------------------------


Salutations!



"twinley" <twinleym(at)hotmail.com> a écrit dans le message de
news:

Bonsoir,

Je crois que j'ai eu tous les N° d'erreurs... Alors si quelqu'un pouvait
me

trouver la bonne syntaxe ?

Je cherche toutes les lignes qui sont en gras dans la colonne A1:A50 de la
feuille 5
Il n'aime pas : Set c = .FindFormat.Font.Bold

Sub findbold()
Range("A1").Select
With Worksheets(5).Range("a1:a50")
With Application.FindFormat.Font
Set c = .FindFormat.Font.Bold
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = True
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub

Merci pour l'aide
--
à+twinley