PDA

View Full Version : I want to change the color of some letters, but it does't work



bocanegra
07-22-2007, 06:44 AM
Hi

In the active cell I have this:

The _hite _one is _uried _ehind the _ardrobe

I have three buttos (button B; button V and button W) to put one letter each time I clic one button. When I clic one button, it fills the first dash with the letter of the button (b, v or w) and then I call this code to check if the clicked letter is ok or not. When I clic again, it fills the second dash with the letter of the button and so on...

wOk contains the correct sentence and wTest contains the sentence that we fill with the letters.

wTest = The _hite _one is _uried _ehind the _ardrobe
wOk = The wite bone is buried behind the wardrobe


I have this code:

'We paint the hits in green and the failures in red

wTest = UCase(Mid(sWord, Pos, 1))
wOk = Cells(iRow, 4).Value
wOk = UCase(Mid(wOk, Pos, 1))



If wTest = wOk Then
With ActiveCell.Characters(Start:=Pos, Length:=1).Font

.Color = RGB(36, 182, 36) 'GREEN (0K)
End With

Else
With ActiveCell.Characters(Start:=Pos, Length:=1).Font
.Color = RGB(255, 0, 0) 'RED (failures)
End With

End If


PROBLEM:
I clic two times... for example: w and v buttons. When I clic w button, the w color is green, because the letter is ok

The White _one is _uried _ehind the _ardrobe

When I clic the second letter (v) must be painted in red, because is an error

The White Vone is _uried _ehind the _ardrobe

In this case it change the colors of the sentence to black
execept de clicked letter

The White Vone is _uried _ehind the _ardrobe

it the first letter is green, the sentence chages to green, execept de clicked letter; if its ret, changes to red...




Is somebody able to help me to solve this mess?

Bob Phillips
07-22-2007, 07:11 AM
Too much missing information for us to hrlp.

Where does iRow get set?
Where does Pos get set?
Where does sWord get set?

Bob Phillips
07-22-2007, 07:14 AM
And what is the code for each button?

An example workbook would be best help.

bocanegra
07-22-2007, 11:27 AM
Here are the sampels. There are two workbooks the first one is may original workbook (excel 2007). There is also a copy in excel 2003. I hope they work fine.

Thaks a lot, xld

Charlize
07-24-2007, 07:13 AM
Variation on your setup. Put every word in a seperate column. Based on that you can compare the word and color the cell if it's incorrect. Take a look at the help worksheet to see how it works.