Bonjour à tous,

Pour bien commencer la semaineune erreur 1004 à la ligne 14 du code.
Quelqu'un connait-t-il l'origine de l'erreur ?

Merci d'avance.

Habiler

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Sub ReplaceColumnAValues()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long
    Dim newValue As Variant

    ' Define the worksheet you want to work with
    Set ws = ThisWorkbook.Sheets("2023") ' Change "Sheet1" to the name of your sheet
    
    ' Find the last row in Column A with data
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
    ' Specify the new value you want to replace with
    newValue = ws.Cells(i, 15) ' Change "NewValue" to the value you want

    ' Loop through each cell in Column A and replace the value
    For i = 2 To lastRow
        ws.Cells(i, 16).Value = newValue
    Next i
End Sub