Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
KCG KCG is offline
external usenet poster
 
Posts: 20
Default VB Macro for cell colour default

Hello there,

I have used up all conditional formatting. Please help me with developing a
Macro for further cell formatting as follows:

I have this range of numbers in the row A10:G10

12 5 26 3 17 38 9 23

If any number in this list is in the range A1:G9, I need the macro to colour
that found value's cell, blue.

Thanx for your help.

Regards


--
KCG
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default VB Macro for cell colour default

Try this. Right click on the worksheet tab that you want this in and paste
it into the worksheet module. If you want to change the colors, here's a
magic decoder ring:

http://www.mvps.org/dmcritchie/excel/colors.htm

Private Sub Worksheet_Change(ByVal Target As Range)
Dim aWS As Worksheet
Dim myRange As Range
Dim r As Range
Dim r1 As Range
Dim myCheckRange As Range

Set aWS = Target.Parent
Set myRange = aWS.Range("A10:G10")
If Not Intersect(Target, myRange) Is Nothing Then
Set myCheckRange = aWS.Range("A1:G9")
For Each r In myRange
For Each r1 In myCheckRange
If r.Value = r1.Value And Not IsEmpty(r) Then
Debug.Print r.Value
r.Interior.ColorIndex = 20
End If
Next r1

Next r

End If


End Sub




"KCG" wrote:

Hello there,

I have used up all conditional formatting. Please help me with developing a
Macro for further cell formatting as follows:

I have this range of numbers in the row A10:G10

12 5 26 3 17 38 9 23

If any number in this list is in the range A1:G9, I need the macro to colour
that found value's cell, blue.

Thanx for your help.

Regards


--
KCG

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VB Macro for cell colour default

Another one:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValRng As Range
Dim myCell As Range
Dim myRngToCheck As Range
Dim myInterSect As Range
Dim res As Variant

Set myValRng = Me.Range("a10:g10")
Set myRngToCheck = Me.Range("a1:g9")

Set myInterSect = Intersect(Target, myRngToCheck)

If myInterSect Is Nothing Then Exit Sub

For Each myCell In myInterSect.Cells
res = Application.Match(myCell.Value, myValRng, 0)
If IsError(res) Then
myCell.Interior.ColorIndex = xlNone
Else
myCell.Interior.ColorIndex = 20
End If
Next myCell
End Sub



KCG wrote:

Hello there,

I have used up all conditional formatting. Please help me with developing a
Macro for further cell formatting as follows:

I have this range of numbers in the row A10:G10

12 5 26 3 17 38 9 23

If any number in this list is in the range A1:G9, I need the macro to colour
that found value's cell, blue.

Thanx for your help.

Regards

--
KCG


--

Dave Peterson
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
Default colour in cell based on specific entry KCG Excel Worksheet Functions 4 August 5th 07 09:26 AM
Default Cell border colour? Tibbs Excel Discussion (Misc queries) 0 June 27th 06 09:40 AM
Update Macro: Leave Colour As Before Once Cell is Not Active JB2010 Excel Discussion (Misc queries) 2 February 2nd 06 06:08 PM
How do you change the default colour a cell is highlighted in? CMorris Excel Discussion (Misc queries) 0 December 14th 05 10:46 AM
Macro to sort by cell colour CoZ Excel Worksheet Functions 1 November 16th 04 05:52 PM


All times are GMT +1. The time now is 03:23 AM.

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"