ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell.value comply with cell.value before and cell.value after (https://www.excelbanter.com/excel-programming/439926-re-cell-value-comply-cell-value-before-cell-value-after.html)

Paul Robinson

cell.value comply with cell.value before and cell.value after
 
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, 2:04*pm, ppeer 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




All times are GMT +1. The time now is 12:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com