MS Excel VBA

I need a macro to place value in column B after reading value in column. In the attached file I have set all the values in column B. The report will repeat the values in A and that is where I would like macro to Pick IC1 or IC2 or IC3 for columb. Can the values be hardcoded in the macro ?

e.g If col A= W03
       Then B = IC3
cluster-server-table.xls
chitralekhaaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

redmondbCommented:
Hi, chitralekhaa.

Please attached. The code is...
Option Explicit
Option Base 0

Sub cLUSTERS()
Dim i As Long
Dim xLast_Row As Long
Dim xData As Variant
Dim xOutput As Variant

Sheets("Sheet1").Activate

xLast_Row = ActiveSheet.UsedRange.Cells(1, 1).Row + ActiveSheet.UsedRange.Rows.Count - 1
If xLast_Row < 2 Then
    MsgBox ("No data found - run cancelled.")
    Exit Sub
End If

xData = Range("A2:A" & xLast_Row)
ReDim xOutput(1 To xLast_Row - 1)

For i = 1 To UBound(xData)
    Select Case xData(i, 1)
        Case "NE01", "NE02", "NE03", "NE04", "NE05", "NE06", "NE07"
            xOutput(i) = "IC1"
        Case "MW01", "SE01", "SE02", "SE03", "SE04", "SW01", "SW02"
            xOutput(i) = "IC2"
        Case "NW01", "NW02", "NW03", "W01", "W02", "W03"
            xOutput(i) = "IC3"
        Case Else
            xOutput(i) = "n/a"
    End Select
Next

Range("B2:B" & xLast_Row) = Application.Transpose(xOutput)

End Sub

Open in new window

Regards,
Brian.cluster-server-table-V2.xls
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chitralekhaaAuthor Commented:
Thank you so much for the this code. It is going to be a great help and you made it so easy.
Thanks
0
redmondbCommented:
Thanks, chitralekhaa!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.