Macro doesnt work properly

Z

Zak

I have the following code, it some how has stopped working properly. The code
tells it if anything meets the given conditions in column E then it should
change the corresponding cell in column F accordingly, instead it changes
everything in column F to "AP" and "sub contractor".

please help. thanks.

Sub ReplaceWithAP()
Dim r As Range
Dim srng As Range
Set srng = Range("E2", Range("E" & Rows.Count). _
End(xlUp)).SpecialCells(xlCellTypeConstants, xlTextValues)
For Each r In srng

Select Case r.Value
Case "Hedra"
myvalue = "AP"
Case "iSOFT"
myvalue = "AP"
Case "Red Tray"
myvalue = "AP"
Case "System C"
myvalue = "AP"
Case "AMS Subcon"
myvalue = "Sub Contractor"
Case "Apollo"
myvalue = "Sub Contractor"
Case "Applabs"
myvalue = "Sub Contractor"
Case "Capula"
myvalue = "Sub Contractor"
Case "Temporary Staff"
myvalue = "Sub Contractor"
End Select

r.Offset(0, 1).Value = myvalue

Next
End Sub
 
M

Mike H

Zak,

The code checks column E and depending on what it finds changes column F to
either AP or Sub Contractor.

What do you expect to happen?

Mike
 
Z

Zak

yes but what it did was change everything in column F to AP or Sub contractor
when it should only change what it is supposed to -depending on the criteria
given.

I have seperated the two conditions now so it works ok.

thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top