MickG,
MrExcel MVP, Congratulations
Hello,
MickG, please if you could, I need slightly modification in the following macro, that produce the constant occurrence result as follow
If data C:P row start with "1" constant occurrence result start in column R
If data C:P row start with "X" constant occurrence result start in column S
If data C:P row start with "2" constant occurrence result start in column T
This is result getting with the above macro
This is what I am looking for shift result as per 1, X or 2
Thank you all
Excel 2000
Regards,
Moti
MrExcel MVP, Congratulations
Hello,
MickG, please if you could, I need slightly modification in the following macro, that produce the constant occurrence result as follow
If data C:P row start with "1" constant occurrence result start in column R
If data C:P row start with "X" constant occurrence result start in column S
If data C:P row start with "2" constant occurrence result start in column T
Code:
Sub MG17Nov19
Dim Rng As Range, Dn As Range, n As Long, K As Variant, R As Range, ac As Long, c As Long
Dim col As Integer
Set Rng = Range("C6", Range("C" & Rows.Count).End(xlUp))
With Rng.Offset(, 15).Resize(, 14)
.Interior.ColorIndex = xlNone
.Font.ColorIndex = 2
End With
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
For ac = 0 To 13
If Not .Exists(Dn.Offset(, ac).Value) Then
.Add Dn.Offset(, ac).Value, Dn.Offset(, ac)
Else
Set .Item(Dn.Offset(, ac).Value) = _
Union(.Item(Dn.Offset(, ac).Value), Dn.Offset(, ac))
End If
Next ac
Dim t
ReDim Ray(1 To 14, 1 To 2)
For Each K In .keys
For Each R In .Item(K).Areas
t = R.Address
Select Case R(1).Value
Case "X": col = 10
Case 1: col = 3
Case 2: col = 5
End Select
Ray(R(1).Column - 2, 1) = R.Count
Ray(R(1).Column - 2, 2) = col
Next R
Next K
.RemoveAll
c = 0
For n = 1 To 14
If Not IsEmpty(Ray(n, 1)) Then
c = c + 1
Dn.Offset(, 14 + c) = Ray(n, 1)
Dn.Offset(, 14 + c).Interior.ColorIndex = Ray(n, 2)
End If
Next n
Next Dn
End With
End Sub
Book1 | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | AE | AF | AG | |||
1 | |||||||||||||||||||||||||||||||||||
2 | |||||||||||||||||||||||||||||||||||
3 | |||||||||||||||||||||||||||||||||||
4 | |||||||||||||||||||||||||||||||||||
5 | P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8 | P9 | P10 | P11 | P12 | P13 | P14 | P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8 | P9 | P10 | P11 | P12 | P13 | P14 | P15 | ||||||
6 | X | 1 | 2 | 2 | 2 | 1 | 1 | 1 | 1 | X | 1 | 1 | 2 | 2 | 1 | 1 | 3 | 4 | 1 | 2 | 2 | ||||||||||||||
7 | 2 | 2 | 1 | X | 1 | X | 2 | X | X | 1 | 2 | X | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | |||||||||
8 | X | X | 1 | 2 | 1 | 2 | X | 1 | 1 | 2 | X | X | X | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 3 | 1 | |||||||||||
9 | 2 | 2 | 1 | 1 | X | 2 | X | 1 | X | 1 | 2 | X | X | 2 | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | ||||||||||
10 | 1 | 2 | X | 1 | X | 1 | 1 | 1 | 1 | X | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 4 | 1 | 3 | 1 | ||||||||||||
11 | 1 | 2 | 2 | X | 1 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 2 | 2 | 4 | |||||||||||||
12 | X | X | 1 | 2 | X | X | 2 | 2 | 1 | 1 | 1 | 1 | X | 2 | 2 | 1 | 1 | 2 | 2 | 4 | 1 | 1 | |||||||||||||
13 | 2 | 1 | 1 | 2 | 1 | X | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 5 | 1 | 2 | |||||||||||||
14 | 1 | 2 | 2 | 2 | 2 | 2 | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 5 | 1 | 1 | 1 | 1 | 4 | ||||||||||||||
15 | 2 | X | 2 | 2 | 2 | 1 | 1 | 1 | X | 1 | X | 1 | 1 | 2 | 1 | 1 | 3 | 3 | 1 | 1 | 1 | 2 | 1 | ||||||||||||
16 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | X | 1 | X | 1 | 1 | 3 | 1 | 4 | 1 | 1 | 1 | 1 | 2 | |||||||||||||
17 | 2 | 2 | 1 | 2 | X | 2 | X | 1 | X | 1 | 1 | 1 | X | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 3 | 1 | 1 | ||||||||||
18 | 2 | 2 | 1 | X | 1 | 2 | 2 | 1 | 1 | X | 1 | 1 | X | 1 | 2 | 1 | 1 | 1 | 2 | 2 | 1 | 2 | 1 | 1 | |||||||||||
19 | X | 2 | 2 | 2 | 2 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | X | 1 | 5 | 1 | 1 | 4 | 1 | 1 | ||||||||||||||
20 | 1 | 2 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | X | X | 2 | X | 1 | 1 | 1 | 2 | 1 | 4 | 2 | 1 | 1 | 1 | ||||||||||||
21 | X | X | X | X | X | X | X | X | X | X | X | X | X | 1 | 13 | 1 | |||||||||||||||||||
22 | 1 | 1 | 1 | 1 | 1 | 1 | X | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 6 | 1 | 7 | ||||||||||||||||||
23 | |||||||||||||||||||||||||||||||||||
24 | |||||||||||||||||||||||||||||||||||
Sheet1 |
This is what I am looking for shift result as per 1, X or 2
Book1 | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | AE | AF | AG | |||
1 | |||||||||||||||||||||||||||||||||||
2 | |||||||||||||||||||||||||||||||||||
3 | |||||||||||||||||||||||||||||||||||
4 | |||||||||||||||||||||||||||||||||||
5 | P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8 | P9 | P10 | P11 | P12 | P13 | P14 | P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8 | P9 | P10 | P11 | P12 | P13 | P14 | P15 | ||||||
6 | X | 1 | 2 | 2 | 2 | 1 | 1 | 1 | 1 | X | 1 | 1 | 2 | 2 | 1 | 1 | 3 | 4 | 1 | 2 | 2 | ||||||||||||||
7 | 2 | 2 | 1 | X | 1 | X | 2 | X | X | 1 | 2 | X | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | |||||||||
8 | X | X | 1 | 2 | 1 | 2 | X | 1 | 1 | 2 | X | X | X | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 3 | 1 | |||||||||||
9 | 2 | 2 | 1 | 1 | X | 2 | X | 1 | X | 1 | 2 | X | X | 2 | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | ||||||||||
10 | 1 | 2 | X | 1 | X | 1 | 1 | 1 | 1 | X | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 4 | 1 | 3 | 1 | ||||||||||||
11 | 1 | 2 | 2 | X | 1 | 2 | 1 | 1 | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 2 | 2 | 4 | |||||||||||||
12 | X | X | 1 | 2 | X | X | 2 | 2 | 1 | 1 | 1 | 1 | X | 2 | 2 | 1 | 1 | 2 | 2 | 4 | 1 | 1 | |||||||||||||
13 | 2 | 1 | 1 | 2 | 1 | X | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 5 | 1 | 2 | |||||||||||||
14 | 1 | 2 | 2 | 2 | 2 | 2 | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 5 | 1 | 1 | 1 | 1 | 4 | ||||||||||||||
15 | 2 | X | 2 | 2 | 2 | 1 | 1 | 1 | X | 1 | X | 1 | 1 | 2 | 1 | 1 | 3 | 3 | 1 | 1 | 1 | 2 | 1 | ||||||||||||
16 | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | X | 1 | X | 1 | 1 | 3 | 1 | 4 | 1 | 1 | 1 | 1 | 2 | |||||||||||||
17 | 2 | 2 | 1 | 2 | X | 2 | X | 1 | X | 1 | 1 | 1 | X | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 3 | 1 | 1 | ||||||||||
18 | 2 | 2 | 1 | X | 1 | 2 | 2 | 1 | 1 | X | 1 | 1 | X | 1 | 2 | 1 | 1 | 1 | 2 | 2 | 1 | 2 | 1 | 1 | |||||||||||
19 | X | 2 | 2 | 2 | 2 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | X | 1 | 5 | 1 | 1 | 4 | 1 | 1 | ||||||||||||||
20 | 1 | 2 | 1 | 1 | 2 | 1 | 1 | 1 | 1 | X | X | 2 | X | 1 | 1 | 1 | 2 | 1 | 4 | 2 | 1 | 1 | 1 | ||||||||||||
21 | X | X | X | X | X | X | X | X | X | X | X | X | X | 1 | 13 | 1 | |||||||||||||||||||
22 | 1 | 1 | 1 | 1 | 1 | 1 | X | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 6 | 1 | 7 | ||||||||||||||||||
23 | |||||||||||||||||||||||||||||||||||
24 | |||||||||||||||||||||||||||||||||||
Sheet2 |
Thank you all
Excel 2000
Regards,
Moti
Last edited: