Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Color formatting with VBA

try somehting like:

Sub Shades()
worksheets("Sheet1").Select <======= Change this to suit
Dim cell As Range
Dim PSP As Worksheet
Set PSP = worksheets("Sheet1") <==== This too
For Each cell In PSP.Range("c8:r30") <==== Also this

If cell.Value < "" Then
If (cell.Value - Date) < 1 Then <===== Option 1(modify to suit)
With cell.Interior
.ColorIndex = 38 <===== Option 1(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) < 14 Then <===== Option 2(modify to suit)
With cell.Interior
.ColorIndex = 36 <===== Option 2(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) < 30 Then <===== Option 3(modify to suit)
With cell.Interior
.ColorIndex = 35 <===== Option 3(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) 1 Then <===== Option 4(modify to suit)
With cell.Interior
.ColorIndex = 2 <===== Option 4(modify to suit) ADD AS MANY AS
REQUIRED
.Pattern = xlSolid
End With
End If
End If
Next
End Sub

--
Regards

Corey


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Color formatting with VBA

A project for my next weekend. Many thanks for your help, Corey.

Brian

"Corey" wrote in message
...
try somehting like:

Sub Shades()
worksheets("Sheet1").Select <======= Change this to suit
Dim cell As Range
Dim PSP As Worksheet
Set PSP = worksheets("Sheet1") <==== This too
For Each cell In PSP.Range("c8:r30") <==== Also this

If cell.Value < "" Then
If (cell.Value - Date) < 1 Then <===== Option 1(modify to suit)
With cell.Interior
.ColorIndex = 38 <===== Option 1(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) < 14 Then <===== Option 2(modify to suit)
With cell.Interior
.ColorIndex = 36 <===== Option 2(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) < 30 Then <===== Option 3(modify to suit)
With cell.Interior
.ColorIndex = 35 <===== Option 3(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) 1 Then <===== Option 4(modify to suit)
With cell.Interior
.ColorIndex = 2 <===== Option 4(modify to suit) ADD AS MANY AS
REQUIRED
.Pattern = xlSolid
End With
End If
End If
Next
End Sub

--
Regards

Corey



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Color formatting with VBA

Managed to find some spare moments. It is now working fine. Thanks for your
well guided instructions. Just one question. Is there a simple way to modify
it so that it can be made available for use at various other workbook
locations?

TIA
Brian

"Corey" wrote in message
...
try somehting like:

Sub Shades()
worksheets("Sheet1").Select <======= Change this to suit
Dim cell As Range
Dim PSP As Worksheet
Set PSP = worksheets("Sheet1") <==== This too
For Each cell In PSP.Range("c8:r30") <==== Also this

If cell.Value < "" Then
If (cell.Value - Date) < 1 Then <===== Option 1(modify to suit)
With cell.Interior
.ColorIndex = 38 <===== Option 1(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) < 14 Then <===== Option 2(modify to suit)
With cell.Interior
.ColorIndex = 36 <===== Option 2(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) < 30 Then <===== Option 3(modify to suit)
With cell.Interior
.ColorIndex = 35 <===== Option 3(modify to suit)
.Pattern = xlSolid
End With
ElseIf (cell.Value - Date) 1 Then <===== Option 4(modify to suit)
With cell.Interior
.ColorIndex = 2 <===== Option 4(modify to suit) ADD AS MANY AS
REQUIRED
.Pattern = xlSolid
End With
End If
End If
Next
End Sub

--
Regards

Corey



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
conditional formatting color Sandy Excel Worksheet Functions 6 October 31st 08 07:17 PM
Color formatting Spancek Excel Worksheet Functions 1 November 21st 07 01:55 PM
Color Formatting Todd Nelson Excel Discussion (Misc queries) 8 April 3rd 06 10:37 PM
Conditional color formatting entries have wild color. John Geyer Excel Discussion (Misc queries) 0 February 24th 06 06:11 PM
Color Formatting Rick Brown Excel Programming 1 October 30th 04 12:44 AM


All times are GMT +1. The time now is 05:17 PM.

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

About Us

"It's about Microsoft Excel"