I Have a column of cells with mixed formatting that I need to both trim leading and trailing spaces, and change the format to text.
This works but is very slow.
Thanks in advance. Needs to work in both Excel 2003 and 2007
Can this be done with the find method ? This is what I have so far -> I know using the asterisk is wrong.Code:Dim Rng As Range Dim tbl As Range Set tbl = Range("G2:G30000") For Each Rng In tbl On Error Resume Next Rng.NumberFormat = "@" Rng = Trim(Rng) Next
Code:Dim c As Range, firstAddress As String Dim Anyvalue Anyvalue = "*" '<-What can I put here so I can perform an operation on every cell? On Error Resume Next Set c = .Find(Anyvalue, LookIn:=xlValues) With ActiveSheet.Range("G2:G30000") If Not c Is Nothing Then firstAddress = c.Address Do c.NumberFormat = "@" c = Trim(c) Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstAddress End If End With




Reply With Quote