Sub HighlightLongTextWithParams(ByVal sheetName As String, ByVal textLength As Integer) Dim ws As Worksheet Dim rng As Range Dim cell As Range ' Get the worksheet from the name passed On Error Resume Next Set ws = ThisWorkbook.Sheets(sheetName) On Error GoTo 0 ' Check if the sheet exists If ws Is Nothing Then MsgBox "Sheet not found! Please check the sheet name.", vbExclamation Exit Sub End If ' Define the range to check Set rng = ws.UsedRange ' Loop through each cell in the range For Each cell In rng If Len(cell.Value) > textLength Then ' Check if text length exceeds the user input cell.Interior.Color = RGB(255, 200, 200) ' Highlight with red color End If Next cell MsgBox "Cells with text longer than " & textLength & " characters have been highlighted.", vbInformation End Sub Sub TestHighlightWithParams() ' Manually pass the parameters (sheet name and text length) Call HighlightLongTextWithParams("Sheet1", 10) End Sub