T
Terry
I've added a line of code to the event below that will uppercase the data in
the last-edited cell but the update takes a few seconds on my PC (probably
longer on the production pc it will eventually run on). Is there a way i can
better place the Ucase code? I've tried, unsuccessfully, to move it outside
the For/Next loop. I won't pretend to understand the Set statement.
Any help would be gratefully appreciated
Terry
Private Sub Worksheet_Change(ByVal Target As Range)
'David McRitchie, 2000-08-08 rev. 2000-08-14
'http://www.mvps.org/dmcritchie/excel/event.htm
'with modifications (TwH)
Dim vLetter As String
Dim vColour As Integer
Dim fColour As Integer
Dim cRange As Range
Dim cell As Range
'***************** check range ****
Set cRange = Intersect(Range("All_Shifts_1"), Range(Target(1).Address))
If cRange Is Nothing Then Exit Sub
'**********************************
For Each cell In Target
vLetter = Len(ActiveCell.Value)
vColour = 3
fColour = 1
Select Case vLetter
Case Is = 0
vColour = 3
Case Is < 5
vColour = 4
Case Is > 5
vColour = 5
fColour = 2
End Select
cell.Interior.ColorIndex = vColour
cell.Font.ColorIndex = fColour
cell.Value = UCase(cell.Value) '********U C A S E
Next cell
'Target.Offset(0, 1).Interior.colorindex = vColour
'use Text instead of Interior if you prefer
End Sub
the last-edited cell but the update takes a few seconds on my PC (probably
longer on the production pc it will eventually run on). Is there a way i can
better place the Ucase code? I've tried, unsuccessfully, to move it outside
the For/Next loop. I won't pretend to understand the Set statement.
Any help would be gratefully appreciated
Terry
Private Sub Worksheet_Change(ByVal Target As Range)
'David McRitchie, 2000-08-08 rev. 2000-08-14
'http://www.mvps.org/dmcritchie/excel/event.htm
'with modifications (TwH)
Dim vLetter As String
Dim vColour As Integer
Dim fColour As Integer
Dim cRange As Range
Dim cell As Range
'***************** check range ****
Set cRange = Intersect(Range("All_Shifts_1"), Range(Target(1).Address))
If cRange Is Nothing Then Exit Sub
'**********************************
For Each cell In Target
vLetter = Len(ActiveCell.Value)
vColour = 3
fColour = 1
Select Case vLetter
Case Is = 0
vColour = 3
Case Is < 5
vColour = 4
Case Is > 5
vColour = 5
fColour = 2
End Select
cell.Interior.ColorIndex = vColour
cell.Font.ColorIndex = fColour
cell.Value = UCase(cell.Value) '********U C A S E
Next cell
'Target.Offset(0, 1).Interior.colorindex = vColour
'use Text instead of Interior if you prefer
End Sub