CharlieC
08-14-2009, 07:09 AM
Hi there,
I'm creating a large monthly report with lots of charts and the core problem is: time taken to update the series colourings when everything shifts with the new data. So...
I have a piece of code which now updates the "Makers" /series within the chart according to a colour formatted range. Thats nice. (Code1)
However, I also have a lot of charts based on "Models" and so need another much larger colour formatted range.
Luckily some fabulous person already made that for us: (Code2 - this copies the formatting to the adjacent cell (for the "Model")
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range
Dim bytColor As Byte
Set Target = Intersect(Target, Range("A1:B500"))
If Target Is Nothing Then Exit Sub
For Each rngCell In Target
Select Case rngCell.Value
Case "Make1"
bytColor = 3 '
Case "Make2"
bytColor = 4 '
Case "Make3"
bytColor = 5 '
Case "Make4"
bytColor = 6 '
Case Else
bytColor = 0 '
End Select
Range(Cells(Target.Row, 1), Cells(Target.Row, 2)).Interior.ColorIndex = bytColor ' copies the format accross A und B
Next rngCell
End Sub
Now this works wonderfully when typing in the values but Unfortunately I have a list of 1600 Makes and Models and when I paste this into the worksheet with the code not an awful lot happens (Unless of course I start typing :bug: )
What I want to be able to do is paste my lengthy columns into the sheet with the code and for the formatting to do its thing.
For info (and if you can't tell already) I have very little training in VBA which is why I'm probably just missing something simple. Hopefully.
many thanks!
I'm creating a large monthly report with lots of charts and the core problem is: time taken to update the series colourings when everything shifts with the new data. So...
I have a piece of code which now updates the "Makers" /series within the chart according to a colour formatted range. Thats nice. (Code1)
However, I also have a lot of charts based on "Models" and so need another much larger colour formatted range.
Luckily some fabulous person already made that for us: (Code2 - this copies the formatting to the adjacent cell (for the "Model")
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range
Dim bytColor As Byte
Set Target = Intersect(Target, Range("A1:B500"))
If Target Is Nothing Then Exit Sub
For Each rngCell In Target
Select Case rngCell.Value
Case "Make1"
bytColor = 3 '
Case "Make2"
bytColor = 4 '
Case "Make3"
bytColor = 5 '
Case "Make4"
bytColor = 6 '
Case Else
bytColor = 0 '
End Select
Range(Cells(Target.Row, 1), Cells(Target.Row, 2)).Interior.ColorIndex = bytColor ' copies the format accross A und B
Next rngCell
End Sub
Now this works wonderfully when typing in the values but Unfortunately I have a list of 1600 Makes and Models and when I paste this into the worksheet with the code not an awful lot happens (Unless of course I start typing :bug: )
What I want to be able to do is paste my lengthy columns into the sheet with the code and for the formatting to do its thing.
For info (and if you can't tell already) I have very little training in VBA which is why I'm probably just missing something simple. Hopefully.
many thanks!