Remplacement des cellules vides

Bonsoir à tous.

Je remplace toutes les cellules vides d'un tableau par "?" en couleur jaune

J'ai fais par ceci. Il y a plus simple ?

Merci de vos propositions !

David

Sub Essais
' Sélection du tableau avec nombre de ligne variables
Dim maPlage As Range
Dim DernLigne As Long

DernLigne = Range("R" & Rows.Count).End(xlUp).Row
Set maPlage = Range("A3:R" & DernLigne) 'à partir de A3

maPlage.Select

' Chercher les cellules vide et remplacer par "?" et mettre en jaune
    With Application.ReplaceFormat.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
End With

    Selection.Replace What:="", Replacement:="?", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=True
End Sub

Bonjour,
Une proposition à adapter.
Cdlt.

Option Explicit

Public Sub Essai()
Dim lastRow As Long, rngData As Range, rngBlanks As Range

    With ActiveSheet
        lastRow = .Cells(.Rows.Count, 18).End(xlUp).Row
        Set rngData = .Cells(3, 1).Resize(lastRow - 2, 18)
        On Error Resume Next
        Set rngBlanks = rngData.SpecialCells(xlCellTypeBlanks)
        On Error GoTo 0
        If Not rngBlanks Is Nothing Then
            With rngBlanks
                .Value = "?"
                .HorizontalAlignment = xlCenter
                .Interior.Color = 65535
            End With
        End If
    End With

End Sub

Merci beaucoup

Re,
Merci de ce retour.
Cdlt.

Rechercher des sujets similaires à "remplacement vides"