View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
hotherps[_140_] hotherps[_140_] is offline
external usenet poster
 
Posts: 1
Default Half of the code works?

This code moves the value Brk out of a series of 8 Cells with a value o
IND. If Brk Occurs in the first 3 cells it moves it to the front of th
8 cell group. If it occurs in the last three cells it should move it t
the end of the 8 cells but it does not.

Am I missing something?

I pasted it in to a clean worksheet within the range, and it still doe
not work all you need to do is type 8 cells with IND in them the
replace the first or second cell with Brk like this

IND IND Brk IND IND IND IND IND

When working the result is
Brk IND IND IND IND IND IND IND

But when it is like this
IND IND IND IND IND IND Brk IND
It does not do this:
IND IND IND IND IND IND IND Brk

Thanks

Dim i As Integer
Dim j As Integer
Dim startcolumn As Integer
Dim endcolumn As Integer
Dim startrow As Integer
Dim endrow As Integer
With Sheet236

startrow = 11
endrow = 298
startcolumn = 7 'Column D
endcolumn = 102 'Column CX

For i = startrow To endrow
For j = startcolumn To startcolumn + 3
If .Cells(i, j).Value = "Brk" Then
.Cells(i, j).Value = "IND"
.Cells(i, startcolumn).Value = "Brk"
End If
Next j
For j = endcolumn - 3 To endcolumn
If .Cells(i, j).Value = "Brk" Then
.Cells(i, j).Value = "IND"
.Cells(i, endcolumn).Value = "Brk"
End If
Next j
Next i

End Wit

--
Message posted from http://www.ExcelForum.com