the_Intern
Board Regular
- Joined
- May 23, 2013
- Messages
- 59
Hi all,
I have two columns of data, CLS and CDS, both of which contain 14365 items. In column CLS these items are labelled either A, B, C, E, F, G, L, R, S, T. In column CDS the items are grouped into two categories X or Y.
Here's the issue: The 1 or 2 categorization is only relevant for CLS items A, B, and R, the rest have been arbitrarily assigned to Y.
I need to write a VBA code that will change the X or Y to N/A (or something like that) for all CLS items C, E, F, G, L, S, T and leave the X or Y ordering alone for A, B, R. It also cannot refernce specific cells. The CLS are in random order so I need something that with recognize the adjacent CLS item and change the CDS value appropriately
Here's what I have so far:
(MODULE 2)
Enum CLS
B = 1
A = 2
R = 3
C = 4
F = 5
E = 6
G = 7
L = 8
S = 9
T = 10
End Enum
Enum CDS
X = 1
Y = 2
NONE = 3
End Enum
(MODULE 1)
Sub Arrange()
Dim MyCLS As CLS
MyCLS = A
MyCLS = B
MyCLS = C
MyCLS = F
MyCLS = E
MyCLS = G
MyCLS = L
MyCLS = R
MyCLS = S
MyCLS = T
Dim MyCDS As CDS
MyCDS = X
MyCDS = Y
MyCDS = NONE
For Each Item In Range("D2:E14365")
If MyCLS >= CI Then
MyCDS = NONE
End If
Next
End Sub (sorry about the length )
I have two columns of data, CLS and CDS, both of which contain 14365 items. In column CLS these items are labelled either A, B, C, E, F, G, L, R, S, T. In column CDS the items are grouped into two categories X or Y.
Here's the issue: The 1 or 2 categorization is only relevant for CLS items A, B, and R, the rest have been arbitrarily assigned to Y.
I need to write a VBA code that will change the X or Y to N/A (or something like that) for all CLS items C, E, F, G, L, S, T and leave the X or Y ordering alone for A, B, R. It also cannot refernce specific cells. The CLS are in random order so I need something that with recognize the adjacent CLS item and change the CDS value appropriately
Here's what I have so far:
(MODULE 2)
Enum CLS
B = 1
A = 2
R = 3
C = 4
F = 5
E = 6
G = 7
L = 8
S = 9
T = 10
End Enum
Enum CDS
X = 1
Y = 2
NONE = 3
End Enum
(MODULE 1)
Sub Arrange()
Dim MyCLS As CLS
MyCLS = A
MyCLS = B
MyCLS = C
MyCLS = F
MyCLS = E
MyCLS = G
MyCLS = L
MyCLS = R
MyCLS = S
MyCLS = T
Dim MyCDS As CDS
MyCDS = X
MyCDS = Y
MyCDS = NONE
For Each Item In Range("D2:E14365")
If MyCLS >= CI Then
MyCDS = NONE
End If
Next
End Sub (sorry about the length )
Last edited: