Results 1 to 6 of 6

Thread: Problem with cells color VB

  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Problem with cells color VB

    Hi,
    I have a table with changing length of the rows and columns and sums at the end of each row/table/diagonal. I want to put some color to the table, but I get error 438 - Object doesn't support this property or method. Here is the code I have:
    Code:
    Sub ColorSet()
    
    Dim cLL As Range, Rg As Range
      Application.ScreenUpdating = False
     For Each cLL In Range("A1:P10")
      If IsEmpty(cLL) Then
       With cLL.Interior
       .ColorIndex = 0
       .Pattern = xlSolid
       End With
      Else
      With cLL.Interior
      .ColorIndex = 3
      .Pattern = xlSolid
      .LineStyle = xlContinuous
      End With
       End If
     Next cLL
     Application.ScreenUpdating = True
       
       End Sub
    Could you help me as I can't figure out what the problem is...

  2. #2
    Join Date
    Feb 2008
    Posts
    194

    Re: Problem with cells color VB

    Microsoft has confirmed this to be a bug in the Microsoft products. There are two possible workarounds for this problem.

    - Access the form directly rather than by a variable containing the form.

    OR

    - Create property procedures in the form's code to provide access to the properties of the controls on the form.

  3. #3
    Join Date
    Jun 2009
    Posts
    3

    Re: Problem with cells color VB

    Could you explain the worarounds in more details?

  4. #4
    Join Date
    Feb 2009
    Posts
    96

    Re: Problem with cells color VB

    Which version of VB are you using... I have run into all kinds of errors in VB.net 2008. One big problem was the way it colors things instead of putting

    x
    .background.color.RED
    . some other property
    . some other property

    i had to type the item lets say
    x.background.color.RED
    x.some other property
    x. some other property

  5. #5
    Join Date
    Jun 2009
    Posts
    3

    Re: Problem with cells color VB

    The version is Microsoft Visual Basic 6.5
    So do I understand right that you mean putting it this way?
    Code:
    Sub ColorSet()
    Dim cLL As Range, Rg As Range
    'Set Rg = Range("A1:P10")
      Application.ScreenUpdating = False
     For Each cLL In Range("A1:P10")
      If IsEmpty(cLL) Then
       cLL.Interior.ColorIndex = 0
       cLL.Interior.Pattern = xlSolid
      Else
       cLL.Interior.ColorIndex = 3
      cLL.Interior.Pattern = xlSolid
      cLL.Interior.LineStyle = xlContinuous
       End If
     Next cLL
     Application.ScreenUpdating = True
       
       End Sub
    If yes - it gives me the same mistake...

  6. #6
    Join Date
    Feb 2009
    Posts
    96

    Re: Problem with cells color VB

    no that only works in vb.net--- I threw that out there in case you were using VB.net

Similar Threads

  1. Replies: 2
    Last Post: 01-02-2012, 01:08 PM
  2. Replies: 3
    Last Post: 01-06-2010, 04:31 AM
  3. Problem with color attribute in CSS
    By Carey in forum Software Development
    Replies: 5
    Last Post: 14-01-2010, 12:20 AM
  4. Problem to combine the values of cells in the order
    By windows_user in forum Software Development
    Replies: 4
    Last Post: 16-04-2009, 11:35 PM
  5. Problem with color pictures.
    By Dietrich in forum Monitor & Video Cards
    Replies: 3
    Last Post: 17-02-2009, 09:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •