PC Review


Reply
Thread Tools Rate Thread

change the background's color for current cell

 
 
moshe_xls
Guest
Posts: n/a
 
      11th Apr 2008
I'm looking for a macro that marks the current cell in worksheet. It has to
be a dynamic function (for any move the current cell will be mark). I want
that the cell will be colored.
Is there a built-in option for that? If yes how can I defined it?

 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      11th Apr 2008
Hi
Put this code in the code module behind the sheet where you want to
colour cells.

Option Explicit
Dim lastCell As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target.Interior.ColorIndex = 6
On Error Resume Next
lastCell.Interior.ColorIndex = xlColorIndexNone
Set lastCell = Target
End Sub

(To see this code module, open the visual basic editor, identify the
sheet in the explorer pane and double click it)

regards
Paul

On Apr 11, 7:48*am, moshe_xls <moshe...@discussions.microsoft.com>
wrote:
> I'm looking for a macro that marks the current cell in worksheet. It has to
> be a dynamic function (for any move the current cell will be mark). I want
> that the cell will be colored.
> Is there a built-in option for that? If yes how can I defined it? *


 
Reply With Quote
 
moshe_xls
Guest
Posts: n/a
 
      11th Apr 2008
Thank you Paul for your replay,

I insert the code as a macro and didn't get anything – how can I make it run?
My be I didn't make my self clear - I want this program to be run
automatically for any cell I will chose (I couldn't understand if it's in the
code).

Best regards,
Moshe

"(E-Mail Removed)" wrote:

> Hi
> Put this code in the code module behind the sheet where you want to
> colour cells.
>
> Option Explicit
> Dim lastCell As Range
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> Target.Interior.ColorIndex = 6
> On Error Resume Next
> lastCell.Interior.ColorIndex = xlColorIndexNone
> Set lastCell = Target
> End Sub
>
> (To see this code module, open the visual basic editor, identify the
> sheet in the explorer pane and double click it)
>
> regards
> Paul
>
> On Apr 11, 7:48 am, moshe_xls <moshe...@discussions.microsoft.com>
> wrote:
> > I'm looking for a macro that marks the current cell in worksheet. It has to
> > be a dynamic function (for any move the current cell will be mark). I want
> > that the cell will be colored.
> > Is there a built-in option for that? If yes how can I defined it?

>
>

 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      14th Apr 2008
Hi
It will run each time you select a cell.
Did you put the macro in the right place? It does NOT go into a
general code module, it goes into the code module behind the
particular sheet you will be selecting cells in. As I said, to see
this code module open the visual basic editor, identify the sheet in
the explorer pane (e.g. sheet1) and double click it.
regards
Paul

On Apr 11, 3:43 pm, moshe_xls <moshe...@discussions.microsoft.com>
wrote:
> Thank you Paul for your replay,
>
> I insert the code as a macro and didn't get anything - how can I make it run?
> My be I didn't make my self clear - I want this program to be run
> automatically for any cell I will chose (I couldn't understand if it's in the
> code).
>
> Best regards,
> Moshe
>
>
>
> "paul.robin...@it-tallaght.ie" wrote:
> > Hi
> > Put this code in the code module behind the sheet where you want to
> > colour cells.

>
> > Option Explicit
> > Dim lastCell As Range

>
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > Target.Interior.ColorIndex = 6
> > On Error Resume Next
> > lastCell.Interior.ColorIndex = xlColorIndexNone
> > Set lastCell = Target
> > End Sub

>
> > (To see this code module, open the visual basic editor, identify the
> > sheet in the explorer pane and double click it)

>
> > regards
> > Paul

>
> > On Apr 11, 7:48 am, moshe_xls <moshe...@discussions.microsoft.com>
> > wrote:
> > > I'm looking for a macro that marks the current cell in worksheet. It has to
> > > be a dynamic function (for any move the current cell will be mark). I want
> > > that the cell will be colored.
> > > Is there a built-in option for that? If yes how can I defined it? - Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
moshe_xls
Guest
Posts: n/a
 
      15th Apr 2008
Thanks its work beautifully :-)

"(E-Mail Removed)" wrote:

> Hi
> It will run each time you select a cell.
> Did you put the macro in the right place? It does NOT go into a
> general code module, it goes into the code module behind the
> particular sheet you will be selecting cells in. As I said, to see
> this code module open the visual basic editor, identify the sheet in
> the explorer pane (e.g. sheet1) and double click it.
> regards
> Paul
>
> On Apr 11, 3:43 pm, moshe_xls <moshe...@discussions.microsoft.com>
> wrote:
> > Thank you Paul for your replay,
> >
> > I insert the code as a macro and didn't get anything - how can I make it run?
> > My be I didn't make my self clear - I want this program to be run
> > automatically for any cell I will chose (I couldn't understand if it's in the
> > code).
> >
> > Best regards,
> > Moshe
> >
> >
> >
> > "paul.robin...@it-tallaght.ie" wrote:
> > > Hi
> > > Put this code in the code module behind the sheet where you want to
> > > colour cells.

> >
> > > Option Explicit
> > > Dim lastCell As Range

> >
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > > Target.Interior.ColorIndex = 6
> > > On Error Resume Next
> > > lastCell.Interior.ColorIndex = xlColorIndexNone
> > > Set lastCell = Target
> > > End Sub

> >
> > > (To see this code module, open the visual basic editor, identify the
> > > sheet in the explorer pane and double click it)

> >
> > > regards
> > > Paul

> >
> > > On Apr 11, 7:48 am, moshe_xls <moshe...@discussions.microsoft.com>
> > > wrote:
> > > > I'm looking for a macro that marks the current cell in worksheet. It has to
> > > > be a dynamic function (for any move the current cell will be mark). I want
> > > > that the cell will be colored.
> > > > Is there a built-in option for that? If yes how can I defined it? - Hide quoted text -

> >
> > - Show quoted text -

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change background color of cell based on vlookup in cell Antney Microsoft Excel Misc 1 19th Oct 2009 10:55 PM
Change tab color based on current color of a cell MarkT Microsoft Excel Misc 0 22nd May 2008 05:46 PM
Change background color based on cell value in vb?? Current code notworking... Naji Microsoft Excel Programming 1 11th Feb 2008 10:15 PM
set the background color of the current cell(active cell) kang Microsoft Excel New Users 2 31st Jul 2007 04:48 PM
Winform (DataGrid) when i'm editing the text, i need to change color/font/background of the current cell Serdge Kooleman Microsoft VB .NET 0 12th Oct 2005 12:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:12 AM.