Range("A1:A10").Interior.ColorIndex = Xlnone

M

MichDenis

Hi,

I may write this :

Range("A1:A10").Interior.ColorIndex = 0

But i could write this too ...
'---------------------
Dim x As Excel.Constants
x = xlNone
Range("A1:A10").Interior.ColorIndex = x
'---------------------

The value of Xlnone = -4142

Any explanations why both methods work ?

Thank for your collaboration and help.
 
M

MichDenis

| Because 0 is white. It removes the border though.

Not on my computer...

Try this :
'-----------------------
Sub test()
Range("A1:A10").Interior.ColorIndex = 0
MsgBox Range("A1").Interior.ColorIndex
End Sub
'-----------------------
Or this,
'-----------------------
Sub test1()
Range("A1:A10").Interior.ColorIndex = xknone
MsgBox Range("A1").Interior.ColorIndex
End Sub
'-----------------------

The message is the same : Message = -4142

Thank for your collaboration.
 
F

FSt1

hi
i think your are a little hung up on thinking that this should be a black
and white issue. not.
see this site.
http://www.mvps.org/dmcritchie/excel/colors.htm
there is no color 0(zero)
there is no color xlnone.
xlnone means(in some cases) revert to defaults. but it is applied to more
that color and interiors.
Range("A1:A10").Font.ColorIndex = xlnone
your msgbox will now say 4.
Range("A1:A10").Linestyle = xlnone
Range("A1").pastespecial Paste:=xlPasteAll, operation = xlnone
and it goes on and on.
understand that many things have more than one word or meaning.
some people call it a pier.
some people call it a warf.
why do we have two words for the same thing?
it is not much different in programming.
why does xlnone have so many meanings?
who know?
the important thing is to learn how to use it in all of its different
meanings.
my thoughts

regards
FSt1
 
F

FSt1

hi
you caught me. usually i test before posting. today i was shooting from the
hip and screwed up some syntax. no problem. the main point i was trying to
make is that in programming there is usually more than one way to do
something. so we should not get hung up on two different ways to do something
just learn to use it the best way we know how and knowing more than one way
comes in handy sometimes.

my thoughts
Regards
FSt1
 

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