Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
922 B
3
Indexable
Sub ReplaceReasonsInColumnL()
    Dim ws As Worksheet
    Dim stationNumber As Integer
    Dim reason As String
    Dim cell As Range
    Dim rng As Range

    ' Define the worksheet
    Set ws = ThisWorkbook.Sheets("Sheet1") ' Change Sheet1 to your sheet name

    ' Define the range of cells in column L to check
    Set rng = ws.Range("L2:L" & ws.Cells(ws.Rows.Count, "L").End(xlUp).Row)

    ' Loop through each station number
    For stationNumber = 201 To 216
        ' Define the standardized reason
        reason = "ST" & stationNumber & " [your reason]" ' Customize the reason text if needed

        ' Loop through each cell in the defined range
        For Each cell In rng
            If InStr(cell.Value, CStr(stationNumber)) > 0 Then
                ' Replace the cell value with the standardized reason
                cell.Value = reason
            End If
        Next cell
    Next stationNumber
End Sub
Leave a Comment