View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ppeer ppeer is offline
external usenet poster
 
Posts: 25
Default cell.value comply with cell.value before and cell.value after

On 24 feb, 16:55, Paul Robinson wrote:
Hi
Try this. It's a bit rough & the first if line is one long line.
Select the single column of info you want to parse & run the sub. Sub
assumes there are at least 3 rows in the column.
Sub tester()
Dim rng As Range
Dim i As Long
Set rng = Selection
With rng
For i = 2 To .Count - 1
* * If Trim(.Cells(i, 1).Value) < Trim(.Cells(i - 1, 1).Value) And
Trim(.Cells(i, 1).Value) < Trim(.Cells(i + 1, 1).Value) Then
* * * * If Trim(.Cells(i - 1, 1).Value) = Trim(.Cells(i + 1, 1)..Value)
Then
* * * * .Cells(i, 1).Value = Trim(.Cells(i - 1, 1).Value)
* * * * End If
* * End If
Next i
End With
Set rng = Nothing
End Sub

regards
Paul

On Feb 24, wrote:



Hi Expert,


In column C which is sorted based on column D, *groups of words
emerge. Occasionally a
deviant word occurs within such a group of uniform words, eg.:


row column C
1 * * Word
2 * * Word
3 * * Word
4 * * ord
5 * * Word
6 * * Word
7 * * From
8 * * From
etc. etc.


Is there some way I can make 'ord' like 'Word' and loop through the
whole of Column C to fix similar situations.
The condition is that ord lies between two similar words, 'Word'. When
row 7 starts with a new group of Words, eg From, this From word will
be left untouched.


Would be happy if you could share some knowledge
ppeer- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -


Works 100% and speed is fast!

best regards
Peter