Thread: If X = Array?
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Incidental Incidental is offline
external usenet poster
 
Posts: 226
Default If X = Array?

Hi Paul

i'm not sure if an array is the easiest way round this sort of of
problem or not but a quick and painless way to do it would be to use
select case on the range of cells holding the account codes the code
below should give you an idea of what i mean

Option Explicit
Dim n As Integer
Dim MyRng, MyCell As Range
Private Sub CommandButton1_Click()

Set MyRng = [A1:A50]

For Each MyCell In MyRng

Select Case MyCell.Value

Case "AAL060", "AAL064", "PFF800"
n = 1
Case "AAL062", "AAL067", "PFF804"
n = 2

End Select

'add your code here

Next MyCell

End Sub

hope this helps you out

Steve