Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
KCG KCG is offline
external usenet poster
 
Posts: 20
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert 2 digit month to 4 digit years and months BB Excel Worksheet Functions 2 September 17th 06 09:33 PM
Color a single digit in a mult-digit number cell Phyllis Excel Discussion (Misc queries) 6 November 17th 05 12:46 AM
How do I identify the 7th digit in a 13 digit number, then establi Catherine Excel Worksheet Functions 7 April 4th 05 06:11 PM
Tell users how to sort 5 digit and 9 digit zipcodes correctly aft. [email protected] New Users to Excel 1 February 18th 05 12:59 AM
When we enter a 16 digit number (credit card) the last digit chan. ceking Excel Discussion (Misc queries) 5 December 8th 04 11:45 PM


All times are GMT +1. The time now is 09:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"