vb 6 writing to excel

This is the code that i use to write to an excel worksheet, my question is how can i set the cell properties so that the back ground color is used.
I've tried backcolor and it did not work.
        xlobj.Worksheets(1).Cells(Rows, 1).Value = rstPipe1.Fields("RecDate")
        xlobj.Worksheets(1).Cells(Rows, 2).Value = rstPipe1.Fields("ReferralContact")
        xlobj.Worksheets(1).Cells(Rows, 3).Value = rstPipe1.Fields("BusinessType")

xlobj.worksheets(1).range(A1:A14).backcolor = somecolor  
this does not work.

any suggestions.

thanx

LVL 1
jtjcompAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dalbelloConnect With a Mentor Commented:
Try this
xlobj.Worksheets(1).Range("A1:A14").Interior.ColorIndex = 5

(0 = default, 1 = black, 2 = white,  3 = red, 4 = green, 5 = blue .... etc ... you can test )
0
 
samopalCommented:
set oRange = xlobj.worksheets(1).range(A1:A14).select
oRange.ColorIndex = YourColor

HTH
0
 
samopalCommented:
Sorry, last line should be

oRange.Interior.ColorIndex = YourColor

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
jtjcompAuthor Commented:
This is the line i used
    xlobj.Worksheets(1).Range("A1:N14").Interior.ColorIndex = vbBlue
and it gave me error 1004 unable to set the colorindex property of the interior class,


any suggestions as to why
0
 
samopalCommented:
Hmm... Try this:

xlobj.worksheets(1).range(A1:A14).select
xlobj.worksheets(1).selection.Interior.ColorIndex = vbBlue
 
I remember that I did it. But now I haven't Excel installed...
0
 
jtjcompAuthor Commented:
no, that did not work either.
0
 
jtjcompAuthor Commented:
That is not working i will reopen the question and see if there  are any other suggestions.
0
 
jtjcompAuthor Commented:
Using a number for the colorindex work!
Thanx for your help, Both of you.

0
 
dalbelloCommented:
jtjcomp
I'm happy to help you.
Thank you.
0
 
dalbelloCommented:
jtjcomp
I'm happy to help you.
Thank you.
0
 
dalbelloCommented:
jtjcomp
I'm happy to help you.
Thank you.
0
 
dalbelloCommented:
jtjcomp
I'm happy to help you.
Thank you.
0
 
dalbelloCommented:
Thanks !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.