![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
|
I wanted to make the active cell on a worksheet appear as a certain color no matter the original color of the cell. So I wrote this code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count <> 1 Then Exit Sub If Not OldTarget Is Nothing Then OldTarget.Interior.Color = OldColor End If OldColor = Target.Interior.Color Set OldTarget = Target Target.Interior.Color = 4848491 End Sub The weird thing is that sometimes target.interior.color doesn't return the correct color value. I'm completely sure about this. I can run a routine to specifically set a cell's interior color to say 4848491, and then without doing anything check the value of the same cell's interior color and the value returned is not the same (it's always 52377). However the cell's actual color on the worksheet is correct. But when the routine above runs the actual color does become 52377. Does anybody have a clue as to what could be going on? Should I use colorindex instead? |
|
|
|
|
|
#2 |
|
New Member
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
|
I was stepping through the code I posted earlier. While stopped at a breakpoint (end sub) I put the cursor over target.interior.color and it gave the value as being 52377. Now it has just been set to 4848491, but it says it is 52377. I am not joking or crazy. But then a minute later without running the code another step, still stopped at the same breakpoint, no changes made by me whatsoever, all of a sudden the value correctly becomes 4848491. I have all of the service packs and everything installed. Is there something wrong I am doing or is there something wrong with VBA here?
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|