Set r = Worksheets("Sheet1").Columns("A").Find(What:=" ")
If r Is Nothing Then
MsgBox "done"
\ End If End Sub
Set r = Worksheets("Sheet1").Columns("A").Find(What:=" ")
If r Is Nothing Then
MsgBox "done"
\ End If End Sub
the below code removes any spaces in the text in col A. Hope this is what you were looking for. Amend the code as necessary. I have done the changes so that it works for the entire sheet. accept the answer by clicking accept if it resolves your requirement
Sub teste()
Dim UsedRng As Range
Dim FirstRow As Long, LastRow As Long, FirstCol As Long, LastCol As Long
Set UsedRng = ActiveSheet.UsedRange
FRow = UsedRng(1).Row
FCol = UsedRng(1).Column
lRow = UsedRng(UsedRng.Cells.Count).Row
Lcol = UsedRng(UsedRng.Cells.Count).Column
For X = FRow To lRow
For Y = FCol To Lcol
temp = Cells(X, Y).Value
tempC = (Trim(temp))
Cells(X, Y).Value = tempC
Next Y
Next X
End Sub