Sorry, there was a typo in the first loop, it should be
For i = 1 To LastRow
If Cells(i, "A").Value <> "" Then
If Cells(i, "D").Value <> "A" And Cells(i, "D").Value <> "N" And
_
Cells(i, "D").Value <> "C" Then
Cells(i, "D").Interior.ColorIndex = 6
End If
End If
Next i
You should declare the variables i and LastRow, and somehow set the LastRow
variable.
--
---
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
"Newman Emanouel" <(E-Mail Removed)> wrote in message
news:55B872F6-C5BC-429E-AB47-(E-Mail Removed)...
> Bob
>
> Thanks for the info but I cant get you script to work. Do I have to define
> any ofthe variables?
>
>
>
> "Bob Phillips" wrote:
>
>> Doesn't sound like Case is needed at all to me, just
>>
>> For i = 1 To LastRow
>> If Cells(i,"A").Value <> "" Then
>> If Cells(i,"D").Value <> "A" <> Cells(i,"D").Value <> "N" And
>> _
>> Cells(I,"D").Value <> "C" Then
>> Cells(I,"D").Interior.Colorindex = 6
>> End If
>> End If
>> Next i
>>
>>
>> You could use case, but it would be superfluous IMO
>>
>> For I = 1 To lastrow
>> Select Case Cells(I, "A").Value
>> Case Is <> "":
>> Select Case Cells(I, "D").Value
>> Case "A", "N", "C": 'do nothing
>> Case Else: Cells(I, "D").Interior.ColorIndex = 6
>> End Select
>> End Select
>> Next I
>>
>> although you might feel the latter is easier to read
>>
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Newman Emanouel" <(E-Mail Removed)> wrote in message
>> news:0C0A44E4-8ACA-4BEF-A04F-(E-Mail Removed)...
>> > Hi OssieMac
>> >
>> > I got your code and it sort of works but just to give you a bit more
>> > clarity
>> >
>> > Column "A" has a list of job numbers and column "D" has a list of codes
>> > which is part of a validation list. So lets say column "D" is to have
>> > say
>> > "A", "N", "C"
>> >
>> > I need the code to do a couple of things, the first is to check whether
>> > a
>> > job number has been allocated therefore column "A" cannot be null then
>> > I
>> > need
>> > it to check to see if column "D" has the right code (ie "A", "N",
>> > "C"),
>> > if
>> > it doesnt to fill the cell colour background yellow and if its ok to
>> > move
>> > onto the next line
>> >
>> > I hope I am a little more clear about my requirements
>> >
>> > Your help is really appreciated.
>> >
>> > Regards
>> >
>> > Newman
>> >
>>
>>
>>
|