Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Array problem (xls 97)

    Could anyone help witht he following. This also appears in a reply in a previous post.

    Sub NumColors()
    Dim x As Integer
    Dim i As Integer
    Dim ncell As Range
    Dim vColors As Variant
    vColors = Array(3, 4, 6, 7, 8, 10, 12)
    'Cells to enter dates are labeled as a range "NUM"
    Range("Num").Select 'Cells to enter dates are labeled as a range "NUM"
    For Each ncell In Selection
    If ncell.Value <> "" Then ' If cell is blank then it gets skipped
    ncell.Interior.ColorIndex = vColors(ncell.Value)
    Else
    ncell.Interior.ColorIndex = xlNone
    End If
    Next ncell
    End Sub

    This line is causing the problem
    ncell.Interior.ColorIndex = vColors(ncell.Value)

    I get an out of range error if left that way.
    If i take out the (ncell.value) it colors everything in as 3(red). Why won't it read the array? If i have 100 different values i need them have different colors based on the array? how can i make 100 different ncell values have at least 30-40 different colors based on what i enter in the array?? I know they cant all have unique values cause there are only 56 colors. I just need some diffrent values based on what i put in the array. thanks for the help.

    Ed

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Array problem (xls 97)

    Please only post a question once. This is the fourth copy of the same question.
    Legare Coleman

Posting Permissions

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