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!

excel color?

Status
Not open for further replies.

Hulisi

Programmer
Jan 28, 2001
31
TR
i have some code for scgrid ocx showing in excel.
here it is:

Dim objXL As Excel.Application
Dim objWB As Excel.Workbook
Dim objWS As Excel.Worksheet
Dim r As Long
Dim c As Long
Dim intRed As Integer
Dim intGreen As Integer
Dim intBlue As Integer

Set objXL = New Excel.Application
Set objWB = objXL.Workbooks.Add
Set objWS = objWB.Worksheets(1)

With objWS

For r = 0 To objGrid.Rows '- 1
For c = 0 To objGrid.Cols '- 1
.Cells(r + 1, c + 1) = objGrid.Text(r - 1, c - 1)
Next
Next

.Cells.Columns.AutoFit
End With

objXL.Visible = True

Set objWS = Nothing
Set objWB = Nothing
Set objXL = Nothing

but i need help...
scgrid's not data but cell color isnt shown in excel..
can you help me?..
please...
 
To get exact syntax for Excel stuff you can record a macro and then copy it (changing references as required) into VB. Cell color looks like:

With Selection.Interior
.Color = &HCCCC00
.Pattern = xlSolid
End With


________________________________________________________________
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
 
i have used your code.it changes only first cell.
how can i change the other cells color?
 
Set your Selection to the appropriate Range. The solution works for any valid Range object

________________________________________________________________
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
 
How can i set Selection to the appropriate Range?
please help me.
 
You need to check up on the properties etc of the Excel Object Model. If you go into Excel, then Alt F11 will take you into VB editor. From there F1|Contents|Visual Basic How-To will get you started.

For this specific question:

Range(Cells(3, 6), Cells(5, 10)).Select

(You will have to put your own values or variables in of course)

________________________________________________________________
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top