Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Formatting?


Alright, we all know how conditional formatting works.


Code:
--------------------

Range("F113:F127").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=($D130=5)"
Selection.FormatConditions(1).Interior.ColorIndex = 50

--------------------


That's an example of what I want.
Doing that; The Collumn "D" stays the same; but the row increases
incrementally.
How would I code something exactly like conditional formatting in VBA?
Where it is able to use all of the excel formulas and everything.

Why I want to know -- I'm using some conditional formatting, but I need
more than the 3 built in choices.

Thanks
~Ryan


--
Zlord
------------------------------------------------------------------------
Zlord's Profile: http://www.excelforum.com/member.php...o&userid=27519
View this thread: http://www.excelforum.com/showthread...hreadid=489279

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Conditional Formatting?

Zlord,

Try this, modify it to your workbook.

Sub Macro1()

Dim cell As Range
Dim eRow As Long

eRow = Range("F2").End(xlDown).Row

For Each cell In Range("F2:F" & eRow)
Select Case cell.Value
Case 0
cell.Interior.ColorIndex = 3
Case 1
cell.Interior.ColorIndex = 6
Case 2
cell.Interior.ColorIndex = 5
Case 3
cell.Interior.ColorIndex = 8
-----
and so on
case .....
cell.Interior.ColorIndex = .....
-----

Case Else
cell.Interior.ColorIndex = xlNone
End Select
Next cell

End Sub


Good luck with it,

grtx's Martijn

"Zlord" schreef in
bericht ...

Alright, we all know how conditional formatting works.


Code:
--------------------

Range("F113:F127").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression,

Formula1:="=($D130=5)"
Selection.FormatConditions(1).Interior.ColorIndex = 50

--------------------


That's an example of what I want.
Doing that; The Collumn "D" stays the same; but the row increases
incrementally.
How would I code something exactly like conditional formatting in VBA?
Where it is able to use all of the excel formulas and everything.

Why I want to know -- I'm using some conditional formatting, but I need
more than the 3 built in choices.

Thanks
~Ryan


--
Zlord
------------------------------------------------------------------------
Zlord's Profile:

http://www.excelforum.com/member.php...o&userid=27519
View this thread: http://www.excelforum.com/showthread...hreadid=489279



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Formatting?


I tried this; didn't work, any ideas how I would do something where when
the case is one of those, then it will color the cells A,strin through
K,strin as a specific color?


Code:
--------------------

Private Sub Worksheet_Change(ByVal Target As Range)
Dim eRow As Integer
Dim strin As Integer
eRow = Range("K2").End(xlDown).Row
strin = 3
For Each cell In Range("K3:K" & eRow)
Select Case cell.Value
Case (cell(K, strin) = "ADMIN. REQUEST") Or (cell(K, strin) = "PARENT REQUEST")
Cells(A, strin).Interior.ColorIndex = 3
Case (cell(K, strin) = "EATING") Or (cell(K, strin) = "INSUBORDINATION")
Row.Interior.ColorIndex = 7
Case (Cells("K19") = "")
Selected.Row.Interior.ColorIndex = 5
Case Else
Row.Interior.ColorIndex = 9
End Select
strin = strin + 1
Next
End Sub

--------------------


--
Zlord
------------------------------------------------------------------------
Zlord's Profile: http://www.excelforum.com/member.php...o&userid=27519
View this thread: http://www.excelforum.com/showthread...hreadid=489279

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Formatting?


not yet answered


--
Zlord
------------------------------------------------------------------------
Zlord's Profile: http://www.excelforum.com/member.php...o&userid=27519
View this thread: http://www.excelforum.com/showthread...hreadid=489279

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
How can I convert conditional formatting into explicit formatting? Patrick Harris Excel Discussion (Misc queries) 0 April 9th 09 12:00 AM
Formatting Conditional Formatting Icon Sets The Rook[_2_] Excel Discussion (Misc queries) 3 March 7th 09 08:48 PM
Formatting cells in a column with conditional formatting? shamor Excel Discussion (Misc queries) 8 May 19th 08 10:11 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
Conditional Formatting that will display conditional data BrainFart Excel Worksheet Functions 1 September 13th 05 05:45 PM


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