Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / October 2003



Tip: Looking for answers? Try searching our database.

Changing background/fill colors of a cell in an Excel Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
phreadBarnz - 15 Oct 2003 01:08 GMT
I'm populating a spreadsheet with an SQL recordset through VB code
(v6.0).
I need to HIGHLIGHT a cell if it meets certain criteria.
I need to know (and trust me, I've looked all over the net/MSDN
library for this) what the cell property is called that allows me to
change the background color of the current cell of my [Excel.Object]
I've tried various code samples that I have found and most of them
return error 13, type mismatch or Invalid Qualifier.
Is this truly difficult or am I missing something?
I am able to make the font bold.  I could also probably make the text
color something else, but I really just want to highlight the cell.
Thanks in advance.
Tim Hansen
Mark Scott [MSFT] - 31 Oct 2003 21:56 GMT
Tim,

You might want to try using code that resembles the following:

Private Sub CommandButton1_Click()
Dim i As String
i = "1"
If Sheets(1).Cells(2, 1).Value > 1 Then
   Range("A" & i).Select
   With Selection.Interior
       .ColorIndex = 4
       .Pattern = xlSolid
   End With
End If

End Sub

Best Regards,

Mark D. Scott, Microsoft

Please do not send email directly to this alias. This is my online account
name for newsgroup participation only.  This posting is provided "As is"
with no warranties, and confers no rights.

> I'm populating a spreadsheet with an SQL recordset through VB code
> (v6.0).
[quoted text clipped - 9 lines]
> Thanks in advance.
> Tim Hansen
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.