DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jan 2005
    New Zealand

    change Excel Cell Forecolor using VB6

    Hi All
    Greetings. The version that I have writtin using LISTVIEW is working very well. I have another interesting problem which is beyong my knowledge. I have been asked to display in the Excel Cell forecolor in RED and not the backcolor if the exported data from ACCESS Sales Table whose sales value did not meet certain value.

    this script is not working:
    objWorksheet.Cells(intRow, intCol).Fill.Schemecolor = vbRed

    Here is part of the overall VB6 script that I have written
    Do Until .EOF
    intCol = 0
    intRow = intRow + 1
    For i = 0 To (.Fields.Count - 1) Step 1
    intCol = intCol + 1

    objWorksheet.Cells(intRow, intCol) = .Fields(i).Value

    If .Fields("SalesAmt").Value < 500 Then
    objWorksheet.Cells(intRow, intCol).Fill.Schemecolor = VbRed
    End If


  2. #2
    Join Date
    Nov 2003
    Portland, OR
    Excel's macro recorder is your friend. Begin recording a macro, then manually perform the action(s) you wish to automate -- in this case, changing the forecolor of a cell -- then look at the code that was recorded. Try this:

    objWorksheet.Cells(intRow, intCol).Font.Color = vbRed
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 7
    Last Post: 02-22-2008, 09:42 AM
  2. vb6 error opening excel
    By Nick313 in forum VB Classic
    Replies: 2
    Last Post: 11-15-2007, 03:16 PM
  3. Detect Excel Version in VB6 Application
    By Ifgash in forum VB Classic
    Replies: 1
    Last Post: 04-23-2006, 02:58 AM
  4. Dynamic cell border color change
    By Scott in forum Web
    Replies: 2
    Last Post: 01-08-2002, 03:54 AM
  5. I'll change from VB6 to C#, and why
    By Phil in Austin in forum .NET
    Replies: 15
    Last Post: 02-08-2001, 12:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.