Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing excel cells color from VB6.0

Status
Not open for further replies.

Hulisi

Programmer
Jan 28, 2001
31
TR
hi.
how can i change any cells color of excel
from visual basic 6.0...
please help me..
 
Please read faq222-2244 to see why you shouldn't post the same question twice!

I have answered this in thread222-952934

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
To expand a bit, the Interior property contains 2 color indexes, Color and ColorIndex. Following are a couple examples:

Cells(2,2).Interior.ColorIndex = 35

Range("A2").Interior.ColorIndex = 35

Sheets(2).Select
Selection.Interior.ColorIndex = 35

As suggested, turn on the macro recorder, change some colors and then look at the code that was generated.

Have a great day!

j2consulting@yahoo.com
 

thanks a lot SBendBuckeye.
i did that

for x=...
.Cells(r + 1, c + 1).Interior.Color = objGrid.CellBackColor(r - 3, c - 1)
next
and it is really work.

but now i have another problem.
i am trying to draw excel's cells edges and combining some
cells
how can i do it.
 
Hello Hulisi,

As before, turn on the Macro recorder, do the things you need to do with borders and see what it generates. I don't know what you mean by combining some cells. Can you give an example of what you are trying to do? Good Luck!


Have a great day!

j2consulting@yahoo.com
 
i will send it your mail with attacment.
please help me...


 
Hello Hulisi,

Check out SpecialCells in Help. If you use it with LastCell (eg LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row, LastCol = Cells.SpecialCells(xlCellTypeLastCell).Column) you can then define a range object to do what you need. Ensure that your formatting tool bar is turned on and then record the formmatting you need. Then do something like the following with the code it creates:

Range(Cells(1,1), Cells(LastRow, LastCol)).yourcodegoeshere

Cells has row first and column second so Cells(1,1) = A1

Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top