Compléter certaines cellules d'un grand tableau

Peut-on avec vba déclarer une variable chaîne commençant par "Arrêt : %", le pourcentage étant un nom qui varit.

Dans mon tableau j'aimerais localiser toutes ces cellules pour écrire :

  • dans la cellule à leur gauche "Dist inter-arrêt" en rouge
  • dans la cellule à leur droite "?" en rouge

Le tableau est grand et automatiser cet ajout serait utile. Voici un exemple en pièce jointe :

Bonne journée,

Avec la fonction Find comme dans le code de ton sujet précédent !

ok merci beaucoup

Bonjour,

Une procédure à tester.

Cdlt.

Option Explicit
Public Sub test()
Dim wb As Workbook
Dim ws As Worksheet
Dim str As String, str2 As String
Dim rngData As Range, c As Range
Dim firstAddress As String

    Application.ScreenUpdating = False
    str = "*Arrêt :"
    str2 = "Dist inter-arrêt"
    Set wb = ActiveWorkbook

    For Each ws In wb.Worksheets
        Set rngData = ws.UsedRange
        With rngData
            Set c = .Find(str, LookIn:=xlValues, lookat:=xlPart)
            If Not c Is Nothing Then
                firstAddress = c.Address
                Do
                    With c.Offset(0, -1)
                        .Value = str2
                        .Font.Color = vbRed
                    End With
                    c.Offset(0, 1).Font.Color = vbRed
                    Set c = .FindNext(c)
                Loop While Not c Is Nothing And c.Address <> firstAddress
            End If
        End With
    Next ws

    Set rngData = Nothing: Set c = Nothing
    Set wb = Nothing

End Sub

Alors là ! merci beaucoup cela a marché directement !

Rechercher des sujets similaires à "completer certaines grand tableau"