![]() |
VB Macro for digit
Hello there,
Please help. I have coloured the cells in Rows A1:E1 blue. Using a macro, I would like Excel to check each value in the above row and colour the corresponding digit value blue in the range A5:E5. (I have used up all 3 Conditional Format options, hence the need to use macros for further cell formatting). Thanx -- KCG |
VB Macro for digit
Here is an example that changes the colour as the value is entered
'----------------------------------------------------------------- Private Sub Worksheet_Change(ByVal Target As Range) '----------------------------------------------------------------- Const WS_RANGE As String = "A5:E5" '<=== change to suit On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target Select Case .Value Case 1: .Offset(-1,0).Interior.ColorIndex = 3 'red Case 2: .Offset(-1,0).Interior.ColorIndex = 6 'yellow Case 3: .Offset(-1,0).Interior.ColorIndex = 5 'blue Case 4: .Offset(-1,0).Interior.ColorIndex = 10 'green Case 5: .Offset(-1,0).Interior.ColorIndex = 38 End Select End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "KCG" wrote in message ... Hello there, Please help. I have coloured the cells in Rows A1:E1 blue. Using a macro, I would like Excel to check each value in the above row and colour the corresponding digit value blue in the range A5:E5. (I have used up all 3 Conditional Format options, hence the need to use macros for further cell formatting). Thanx -- KCG |
All times are GMT +1. The time now is 06:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com