Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Interior Color Macro

On line six below, the interior color should be set to 36 only when:
1. Cell B38 is selected (by the "GoTo" macro)
2. The worksheet is active.
So, when another cell is selected, or the user leaves the worksheet, the
cell returns to its original interior color.

How should this code be modified?

Sub GoToTFMChangeRequestWorksheetComptroller()
Application.ScreenUpdating = False
Sheets("TFM Change Request Worksheet").Select
Application.Goto Reference:=Range("A38"), Scroll:=True
Application.Goto Reference:=Range("B38"), Scroll:=False 'Places curser off
screen
Selection.Interior.ColorIndex = 36
ActiveWindow.Zoom = 100
Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Interior Color Macro

You could put this code behind the worksheet affected, the event trigger
will test if cell B38 is selected and change the color, else reset
it.........

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$38" Then
Range("B38").Interior.ColorIndex = 36
Else
Range("B38").Interior.ColorIndex = 0
End If
End Sub

--
Cheers
Nigel



"Phil H" wrote in message
...
On line six below, the interior color should be set to 36 only when:
1. Cell B38 is selected (by the "GoTo" macro)
2. The worksheet is active.
So, when another cell is selected, or the user leaves the worksheet, the
cell returns to its original interior color.

How should this code be modified?

Sub GoToTFMChangeRequestWorksheetComptroller()
Application.ScreenUpdating = False
Sheets("TFM Change Request Worksheet").Select
Application.Goto Reference:=Range("A38"), Scroll:=True
Application.Goto Reference:=Range("B38"), Scroll:=False 'Places curser

off
screen
Selection.Interior.ColorIndex = 36
ActiveWindow.Zoom = 100
Application.ScreenUpdating = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Interior Color Macro

Hi Nigel,

Your code works exactly as intended. Thanks.
Can we take this a step further? In the worksheet there are now five merged
cell ranges that need to be treated the same way: A3:M3; A23:M23; A38:M38
(instead of the single cell B38); A49:M49; and A55:M55. What would the code
be?
Thanks, Phil


"Nigel" wrote:

You could put this code behind the worksheet affected, the event trigger
will test if cell B38 is selected and change the color, else reset
it.........

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$38" Then
Range("B38").Interior.ColorIndex = 36
Else
Range("B38").Interior.ColorIndex = 0
End If
End Sub

--
Cheers
Nigel



"Phil H" wrote in message
...
On line six below, the interior color should be set to 36 only when:
1. Cell B38 is selected (by the "GoTo" macro)
2. The worksheet is active.
So, when another cell is selected, or the user leaves the worksheet, the
cell returns to its original interior color.

How should this code be modified?

Sub GoToTFMChangeRequestWorksheetComptroller()
Application.ScreenUpdating = False
Sheets("TFM Change Request Worksheet").Select
Application.Goto Reference:=Range("A38"), Scroll:=True
Application.Goto Reference:=Range("B38"), Scroll:=False 'Places curser

off
screen
Selection.Interior.ColorIndex = 36
ActiveWindow.Zoom = 100
Application.ScreenUpdating = True
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Interior Color Macro

'-----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "A3,A23,A38,A49,A55"
Dim cell As Range

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Interior.ColorIndex = 36
End With
Else
For Each cell In Me.Range(WS_RANGE)
cell.Interior.ColorIndex = xlColorIndexNone
Next cell
End If

End Sub



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Phil H" wrote in message
...
Hi Nigel,

Your code works exactly as intended. Thanks.
Can we take this a step further? In the worksheet there are now five

merged
cell ranges that need to be treated the same way: A3:M3; A23:M23; A38:M38
(instead of the single cell B38); A49:M49; and A55:M55. What would the

code
be?
Thanks, Phil


"Nigel" wrote:

You could put this code behind the worksheet affected, the event trigger
will test if cell B38 is selected and change the color, else reset
it.........

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$38" Then
Range("B38").Interior.ColorIndex = 36
Else
Range("B38").Interior.ColorIndex = 0
End If
End Sub

--
Cheers
Nigel



"Phil H" wrote in message
...
On line six below, the interior color should be set to 36 only when:
1. Cell B38 is selected (by the "GoTo" macro)
2. The worksheet is active.
So, when another cell is selected, or the user leaves the worksheet,

the
cell returns to its original interior color.

How should this code be modified?

Sub GoToTFMChangeRequestWorksheetComptroller()
Application.ScreenUpdating = False
Sheets("TFM Change Request Worksheet").Select
Application.Goto Reference:=Range("A38"), Scroll:=True
Application.Goto Reference:=Range("B38"), Scroll:=False 'Places

curser
off
screen
Selection.Interior.ColorIndex = 36
ActiveWindow.Zoom = 100
Application.ScreenUpdating = True
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Interior Color Macro

Thanks Bob, it works perfectly! Appriciate your time and expertise.

"Bob Phillips" wrote:

'-----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "A3,A23,A38,A49,A55"
Dim cell As Range

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Interior.ColorIndex = 36
End With
Else
For Each cell In Me.Range(WS_RANGE)
cell.Interior.ColorIndex = xlColorIndexNone
Next cell
End If

End Sub



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Phil H" wrote in message
...
Hi Nigel,

Your code works exactly as intended. Thanks.
Can we take this a step further? In the worksheet there are now five

merged
cell ranges that need to be treated the same way: A3:M3; A23:M23; A38:M38
(instead of the single cell B38); A49:M49; and A55:M55. What would the

code
be?
Thanks, Phil


"Nigel" wrote:

You could put this code behind the worksheet affected, the event trigger
will test if cell B38 is selected and change the color, else reset
it.........

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$38" Then
Range("B38").Interior.ColorIndex = 36
Else
Range("B38").Interior.ColorIndex = 0
End If
End Sub

--
Cheers
Nigel



"Phil H" wrote in message
...
On line six below, the interior color should be set to 36 only when:
1. Cell B38 is selected (by the "GoTo" macro)
2. The worksheet is active.
So, when another cell is selected, or the user leaves the worksheet,

the
cell returns to its original interior color.

How should this code be modified?

Sub GoToTFMChangeRequestWorksheetComptroller()
Application.ScreenUpdating = False
Sheets("TFM Change Request Worksheet").Select
Application.Goto Reference:=Range("A38"), Scroll:=True
Application.Goto Reference:=Range("B38"), Scroll:=False 'Places

curser
off
screen
Selection.Interior.ColorIndex = 36
ActiveWindow.Zoom = 100
Application.ScreenUpdating = True
End Sub







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
Macro to set cell interior color? imoose Excel Discussion (Misc queries) 4 July 8th 08 11:36 PM
No Interior Color Macro simplymidori[_2_] Excel Discussion (Misc queries) 1 April 11th 08 05:01 AM
Sum all cells with interior color... Ctech[_65_] Excel Programming 4 January 11th 06 07:46 PM
Print without Interior Color bhofsetz Excel Discussion (Misc queries) 2 July 19th 05 04:28 PM
Passing Back Color to Interior Color ExcelMonkey[_190_] Excel Programming 1 March 22nd 05 04:27 PM


All times are GMT +1. The time now is 01:26 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"