PDA

View Full Version : Excel Cell Color



nandipati
01-10-2008, 11:21 AM
Hi,

I got to do a code change which involves reading the color of a cell in Excel and impose some condition if the cell color is "Yellow",

Can any body please give me a rough idea on this, iam not really a VBA developer , i work as a cognos developer , but i was given this taks to do,

So i don't know if it is really a simple or complex one,

Hoping for some help :)

Thanks

Bob Phillips
01-10-2008, 11:31 AM
If Range("A1").Interior.Colorindex = 6 Then
'your code
End If

nandipati
01-10-2008, 11:45 AM
Hi,
Thank you so much for the quick reply, One more favor, can you please tell me what is "A1" and is color index "6" for every color?
In my case i have to check for "Yellow",
:confused4 please excuse me as my questions are lil foolish as i don't have knowledge on this

Thanks

Bob Phillips
01-10-2008, 11:56 AM
A1 is the cell on the spreadsheet cell being checked, 6 is the colorindex for yellow.

nandipati
01-10-2008, 11:57 AM
got it, Thank you

nandipati
01-10-2008, 02:51 PM
Hi,
Can you please tell me how to read a particular number from the content of a cell,
For ex: if the cell value is "34256789 Sample 1", how can i read just the last digit("1")?
My team lead told me to read the value from right until i hit the first space,
Can you please help me with this?
Thanks,

Bob Phillips
01-10-2008, 03:09 PM
With Range("A1")
MsgBox Right(.Value, Len(.Value) - InStrRev(.Value, " "))
End With

nandipati
01-14-2008, 08:45 AM
Thank you very much, Can you please tell me how can i assign this to a filed called "sample number"

I mean is it like
SampleNumber = "With Range("A1")
MsgBox Right(.Value, Len(.Value) - InStrRev(.Value, " "))
End With

Can you please give me an idea?

Thanks

nandipati
01-14-2008, 12:55 PM
Hello There,
The function to get the color of the cell didn't work for me
It is giving the error like "Error is 1004 Method 'Range' of object '_Global' failed"
Can you please help me with this?

Thanks,