Change Column Items Based on Multiple Criteria (VBA)

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 :eeek:)
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top