This works but need to extend range

H

hotherps

This code works fine, it moves the vale "Brk" from anywhere in a grou
of 8 cells to the begining or end depending on it's placement.

However it only works in column G. If it finds "Brk", it needs to b
moved to either end regardless of where the 8 cells that contain th
value are, the group of 8 cells could be anywhere in the range of G11
CX298

Thanks


Dim Rng As Range
Dim c As Integer
Dim r As Integer
Dim x As Integer

With ActiveSheet
Set Rng = Range("G11:CX30")
For c = 1 To Rng.Columns.Count Step 10
For r = 1 To Rng.Rows.Count
On Error Resume Next
x = WorksheetFunction.Match("Brk", Rng.Range(Cells(r, c)
Cells(r, c + 9)), 0)

If Err = 0 Then
If Rng.Cells(r, c).Value = "IND" Then
Select Case x
Case 1 To 4
Rng.Cells(r, c - 1).Value = "Brk"
Rng.Cells(r, c + x - 1).Value = "IND"
Case 5 To 8
c = c + 1
x = x - 1
Rng.Cells(r, c + 7).Value = "Brk"
Rng.Cells(r, c + x - 1).Value = "IND"
End Select
End If
Else
Err.Clear
End If
Next r
Next c
End Wit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top