Applying a style depending on currently selected cell?

A

AlanJCarr

Hi guys,

I want to create a Macro which styles the cell selected by the user an
the 10 adjacent cells on the same row green. I'm a bit confused as wha
to set the range as, the cell selected will always be in C and I want i
highlighted up to M of the selected row only.

Range("XXX").Select
Selection.Style = "Good
 
C

Claus Busch

Hi Alan,

Am Tue, 11 Jun 2013 14:56:33 +0100 schrieb AlanJCarr:
I want to create a Macro which styles the cell selected by the user and
the 10 adjacent cells on the same row green. I'm a bit confused as what
to set the range as, the cell selected will always be in C and I want it
highlighted up to M of the selected row only.

put the code into the code module of the expected sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Columns("C")) Is _
Nothing Then Exit Sub

With ActiveSheet
.UsedRange.Interior.ColorIndex = 0
End With
Target.Resize(, 11).Interior.ColorIndex = 4
End Sub

Regards
Claus Busch
 
X

xlmastermacro

Hi guys,



I want to create a Macro which styles the cell selected by the user and

the 10 adjacent cells on the same row green. I'm a bit confused as what

to set the range as, the cell selected will always be in C and I want it

highlighted up to M of the selected row only.



Range("XXX").Select

Selection.Style = "Good"

Al, per chance, were/are you from Northern Ohio?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top