![]() |
Highlighting leading or trailing spaces
I have church members who submit Excel 2003 spreadsheets to me with name and
address information in columns A thru E (Name, address, city, state, zip). Some sheets are submitted with either leading or trailing spaces in various cells. I would like a macro that would inspect each cell in every column for leading or trailing spaces and highlight them with a blue background color so that the users can see the spaces when I return the sheets to them. Thanks, Jack |
Highlighting leading or trailing spaces
What about a macro that simply removes any leading or trailing spaces
instead... Sub RemoveLeadingTrailingBlanks() Dim X As Long, Z As Long, LastRow As Long LastRow = Cells(Rows.Count, "A").End(xlUp).Row For X = 1 To LastRow For Z = 1 To 5 Cells(X, Z).Value = Trim(Cells(X, Z).Value) Next Next End Sub -- Rick (MVP - Excel) "JackGombola" wrote in message ... I have church members who submit Excel 2003 spreadsheets to me with name and address information in columns A thru E (Name, address, city, state, zip). Some sheets are submitted with either leading or trailing spaces in various cells. I would like a macro that would inspect each cell in every column for leading or trailing spaces and highlight them with a blue background color so that the users can see the spaces when I return the sheets to them. Thanks, Jack |
Highlighting leading or trailing spaces
I think it's a better idea to fix the problem, too. But if you want...
If you're not using conditional formatting, you could use that. Select your range to format (say A1:x9999) With A1 the activecell format|conditional formatting formula is: =(COUNTIF(A1," *")+COUNTIF(A1,"* "))0 and give it a nice pattern. JackGombola wrote: I have church members who submit Excel 2003 spreadsheets to me with name and address information in columns A thru E (Name, address, city, state, zip). Some sheets are submitted with either leading or trailing spaces in various cells. I would like a macro that would inspect each cell in every column for leading or trailing spaces and highlight them with a blue background color so that the users can see the spaces when I return the sheets to them. Thanks, Jack -- Dave Peterson |
All times are GMT +1. The time now is 08:36 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com