I have several columns of dates. The dates are formatted as text with a leading space before each one. I'd like to be able to highlight the range, and have the leading spaces removed and the format set as mm/dd/yy. I have the following, but it does not allow me to highlight the range. As you can see, it moves down the column, but it doesn't handle blank cells and quits when it encounters one. Thanks for any help.
Sub FormatDate()
Dim cell As Range
Set cell = Sheet1.Range("A1")
Do
cell.Value = Trim(cell)
cell.NumberFormat = "mm/dd/yyyy"
Set cell = cell.Offset(1, 0)
Loop Until cell.Value = ""
End Sub
Bookmarks