LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Find Length and Format and Compare

On May 13, 8:53*am, Matthew Herbert
wrote:
HelperBee,

Here is some code that should at least give you an idea of how this can
work. *The code runs on a selection of cells. *Since you didn't provide
example data, I made some assumptions. *(For example, I don't know what you
mean by "one word and abbreviation per cell").

Best,

Matthew Herbert

Sub FindLengthAndReplace()
Dim Rng As Range
Dim rngCell As Range

Set Rng = Selection

'loop each cell in the Selection
For Each rngCell In Rng.Cells
* * With rngCell
* * * * 'If the character length of the value within the cell
* * * * ' * is greater than or equal to 30, then color the
* * * * ' * cell and perform the desired replacements specified
* * * * ' * below. *(If no replacements are found, nothing
* * * * ' * happens).
* * * * If Len(.Value) = 30 Then
* * * * * * .Interior.ColorIndex = 16 'use a desired number here
* * * * * * .Value = Replace(.Value, "Insurance", "Insur")
* * * * * * .Value = Replace(.Value, "Payment", "Pymt")
* * * * * * .Value = Replace(.Value, "Invoice", "Inv")
* * * * End If
* * End With
Next rngCell
End Sub



"HelperBee" wrote:
I need to search all the cells in a worksheet for values longer than 30
characters and shade those cells yellow.
For each of the yellow cells I need to compare the contents to see if they
contain words to be abbreviated. *I have a two column worksheet where one
column has the search words and the other has the abbreviations.
I need to read each of the over 30 cells that were shaded and replace each
word in the abbreviation list with the abbreviated version.


Note: multiple words within a cell could need abbreviation, e.g. Insurance
Payment Invoice could be in the cell and get abbreviated to Insur Pymt Inv,
only one word and abbreviation per cell in my abbreviation file.


Thoughts?


I've used the conditional formatting in 2007 which works great for finding
the 30 characters and shading them, but when it comes to the abbreviations
I've been stuck with manual comparison.


Help appreciated, dozens of files to apply this to.


Thanks.- Hide quoted text -


- Show quoted text -


Have you tried with autocorrect feature for replacement of text.

You can use
Application.Autocorrect.AddReplacement What As String, Replacement As
String
for adding your replacement table.



 
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
Find the Length of a Text File Dan R. Excel Programming 4 June 14th 07 09:40 PM
Find length of string - firstfolder dd Excel Programming 5 February 6th 07 01:17 PM
Find and Length Marc Excel Worksheet Functions 6 December 29th 05 03:59 PM
find radius from chord length kimtp Excel Discussion (Misc queries) 4 June 2nd 05 06:40 PM
Format Same Length Always? sailingdan[_5_] Excel Programming 0 August 26th 04 09:29 PM


All times are GMT +1. The time now is 10:29 PM.

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"