Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    color count set range (Excel 2002)

    Hi all,
    I'm trying count a set range and use a function with the set range.....maybe someone could tell me if what I 'm trying to do is correct....I like using cells because I can use variables to set the row and column....can I do it?

    Thanks Darryl.

    If zonefilm = 1 Then
    set Rcomfilm = Sheets("Edition_Main").Range(Cells(4, 1), Cells(68, 1))
    x = CBC(Rcomfilm, 4, False)
    debug.print x





    Function CBC(InRange As Range, WhatColorIndex As Integer, Optional OfText As Boolean = False) As Long
    '
    '
    Dim Rng As Range
    Application.Volatile False
    For Each Rng In InRange
    If OfText = True Then
    CBC = CBC - _
    (Rng.Font.ColorIndex = WhatColorIndex)
    Else
    CBC = CBC - _
    (Rng.Interior.ColorIndex = WhatColorIndex)
    End If
    Next Rng

    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: color count set range (Excel 2002)

    If you want to call this from another sheet than Edition_Main, you must use
    <code>
    set Rcomfilm = Sheets("Edition_Main").Range(Sheets("Edition_Main" ).Cells(4, 1), Sheets("Edition_Main").Cells(68, 1))
    </code>
    or
    <code>
    With Sheets("Edition_Main")
    set Rcomfilm = .Range(.Cells(4, 1), .Cells(68, 1))
    End With
    </code>
    If you don't specify the sheet explicitly, a range is assumed to be on the active sheet.

Posting Permissions

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