Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
removing leading and trailing spaces Ram Excel Programming 1 October 31st 07 10:57 PM
how do I remove leading spaces and leave the remianing spaces w Debi Excel Worksheet Functions 6 February 28th 07 03:29 PM
Removing leading/trailing spaces Chuda Excel Discussion (Misc queries) 2 September 12th 06 04:20 PM
How keep Leading/Trailing spaces when save in Excel? jorgejulio Excel Discussion (Misc queries) 0 August 1st 06 09:49 PM
Delete leading or trailing blank spaces in cell - an example DataFreakFromUtah Excel Programming 2 September 16th 04 10:04 PM


All times are GMT +1. The time now is 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"