Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 3
Default Applying a style depending on currently selected cell?

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"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Applying a style depending on currently selected cell?

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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Applying a style depending on currently selected cell?

On Tuesday, June 11, 2013 9:56:33 AM UTC-4, AlanJCarr wrote:
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"









--

AlanJCarr


Al, per chance, were/are you from Northern Ohio?
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
2B or not 2B? - Go to cell Bx, depending on what row is selected bony_tony Excel Programming 2 April 24th 07 06:04 AM
Applying Indian comma style NAVEEN Excel Discussion (Misc queries) 1 February 22nd 06 08:59 AM
Applying style to row, getting Run-time error '450' Dustin Carter[_2_] Excel Programming 2 December 9th 05 02:26 AM
Want add color to the cell depending on the value selected from th Tom Ogilvy Excel Programming 0 August 16th 05 07:11 PM
applying function depending on condition in other cell [email protected] Excel Programming 5 April 21st 05 03:12 PM


All times are GMT +1. The time now is 10:45 PM.

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

About Us

"It's about Microsoft Excel"