For Each OneCell In Ws.UsedRange.SpecialCells(xlCellTypeConstants)
      If ......... Then
          OneCell = WorksheetFunction.Trim(OneCell)    'Error 2023
          'How to add some code to display which cell causes error 2023. Such as sheet name, row number, column number.
      End If

Next OneCell

The program works fine on most files, so there is no code issue.

How to add some code to display which cell causes the program. Such as sheet name, row number, column number. This part of code will not be part of program, but it is used for programmer to find out which cell causes the issue. Probably some cells come with formulas and it does not work well with Trim function. Now I would like to add some code to find out which cell causes the first Error 2023.

Maybe I should use If Error Then Display message for user.

Thanks.