Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Highlighting Range of Cells based on another cell with 5 condition

Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would appreciate a
code for this.

-Thank you


  #2   Report Post  
Posted to microsoft.public.excel.programming
ADG ADG is offline
external usenet poster
 
Posts: 76
Default Highlighting Range of Cells based on another cell with 5 condition

Hi Alex

Try using conditioal formating to achieve your goal I think this will be
easier than using VBA.
--
Tony Green


"Alex" wrote:

Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would appreciate a
code for this.

-Thank you


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Highlighting Range of Cells based on another cell with 5 condi

There are 5 conditions. The conditional formatting only allows three
condition.

"ADG" wrote:

Hi Alex

Try using conditioal formating to achieve your goal I think this will be
easier than using VBA.
--
Tony Green


"Alex" wrote:

Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would appreciate a
code for this.

-Thank you


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Highlighting Range of Cells based on another cell with 5 condition

If M10 were GI, would A10:N10 go orange as well?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Alex" wrote in message
...
Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would appreciate a
code for this.

-Thank you




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Highlighting Range of Cells based on another cell with 5 condi

Yes. depending what M is would highlight the row accordingly.

"Bob Phillips" wrote:

If M10 were GI, would A10:N10 go orange as well?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Alex" wrote in message
...
Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would appreciate a
code for this.

-Thank you







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Highlighting Range of Cells based on another cell with 5 condi


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "M10:M500"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case "GI": .Offset(0,-12).Resize(,12).Interior.ColorIndex =
46 'orange
Case "CA": .Offset(0,-12).Resize(,12).Interior.ColorIndex =
6 'yellow
'etc.
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Alex" wrote in message
...
Yes. depending what M is would highlight the row accordingly.

"Bob Phillips" wrote:

If M10 were GI, would A10:N10 go orange as well?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Alex" wrote in message
...
Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells

for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would

appreciate a
code for this.

-Thank you







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Highlighting Range of Cells based on another cell with 5 condi

How would I use this as a macro. So when I hit Ctrl+D the code would be run.
Also the criteria is a formula, which the code doesn't work. For example
GI, HO are calculated through a formula.

"Bob Phillips" wrote:


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "M10:M500"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case "GI": .Offset(0,-12).Resize(,12).Interior.ColorIndex =
46 'orange
Case "CA": .Offset(0,-12).Resize(,12).Interior.ColorIndex =
6 'yellow
'etc.
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Alex" wrote in message
...
Yes. depending what M is would highlight the row accordingly.

"Bob Phillips" wrote:

If M10 were GI, would A10:N10 go orange as well?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Alex" wrote in message
...
Hi, I'm pretty new with VBA. I'm trying to highlight a range of cells

for
example (A10:N500) based on cells located in column M. If M10=CA Then
A10:N10 will be highlighted yellow Else If M11=GI Then A11:N11 will be
highlighted orange and about three more coniditons. I would

appreciate a
code for this.

-Thank you








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
highlighting a cell when using a condition formula Ray Excel Discussion (Misc queries) 1 March 13th 09 11:34 AM
Highlighting rows based on one cell [email protected] Excel Worksheet Functions 3 December 13th 07 11:34 PM
Copy range based on condition Sotomayor Excel Programming 1 September 10th 06 01:11 AM
How to copy only some rows from range based on condition? [email protected][_2_] Excel Programming 2 January 30th 06 01:04 AM
conditional formating - Highlighting text cells based on sales res ANDREW_B Excel Discussion (Misc queries) 7 December 2nd 04 04:27 PM


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