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

This is a 3 part question. I have a workbook with several sheets. The one I
am concerned with is PCEMS. This sheet has a chart for each year beginning
with 2006. I want to change the color of two rows when the workbook is
opened. This will be done via conditional formatting using VBA. The two
rows represent the current payperiod.

Within each chart are 52 weeks (ie 52 rows not counting headers, etc). I
can figure out how to locate the correct chart based on year and then
payperiod, I just need to figure out the following:

1) How to execute macro when workbook is opened?

2) What is the code to change the color for the cells?

3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Thanks,
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Conditional formatting a range

hi,
you have confused me.
first you don't need vba to set conditional formating.
if you are going to use conditional formating, what condition would cause
the color change. what color. this sniplet answers all three of your
questions but the conditonal formating seems not to fit. advise.

Private Sub Workbook_Open()
Range("A10:J15").Interior.ColorIndex = 3
End Sub

regards
FSt1
"WLMPilot" wrote:

This is a 3 part question. I have a workbook with several sheets. The one I
am concerned with is PCEMS. This sheet has a chart for each year beginning
with 2006. I want to change the color of two rows when the workbook is
opened. This will be done via conditional formatting using VBA. The two
rows represent the current payperiod.

Within each chart are 52 weeks (ie 52 rows not counting headers, etc). I
can figure out how to locate the correct chart based on year and then
payperiod, I just need to figure out the following:

1) How to execute macro when workbook is opened?

2) What is the code to change the color for the cells?

3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Thanks,
Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Conditional formatting a range

Hi Les,

1) How to execute macro when workbook is opened?

Use Workbook_Open event. In VBE project window, right click ThisWorkbook.
Example code below:

Private Sub Workbook_Open()
'Macro name goes here
End sub

2) What is the code to change the color for the cells?

First, set your range to a variable.

Set myRange = Sheets(2).Range("B2:G500")

Second, Use condition for evaluation to execute change

If myRange.FormatConditions(1).Interior.ColorIndex < 3 Then
myRange.FormatConditions(1).Interior.ColorIndex = 3
End If

If you are not using Conditional Formatting to color the cells
initially, then omit the FormatConditions(1) part of the above
code. The cells interior can be colored on two levels and
the color change has to be on the same level.


3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Yes, the entire range can be changed in one action. It is the Interior
property that keys the change.

"WLMPilot" wrote:

This is a 3 part question. I have a workbook with several sheets. The one I
am concerned with is PCEMS. This sheet has a chart for each year beginning
with 2006. I want to change the color of two rows when the workbook is
opened. This will be done via conditional formatting using VBA. The two
rows represent the current payperiod.

Within each chart are 52 weeks (ie 52 rows not counting headers, etc). I
can figure out how to locate the correct chart based on year and then
payperiod, I just need to figure out the following:

1) How to execute macro when workbook is opened?

2) What is the code to change the color for the cells?

3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Thanks,
Les

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Conditional formatting a range

this might be a more meaningful way to approach the change.

If myRange.FormatConditions.Count 0 Then
myRange.FormatConditions(1).Interior.ColorIndex = 3
Else
myRange.Interior.ColorIndex = 3
End If


"WLMPilot" wrote:

This is a 3 part question. I have a workbook with several sheets. The one I
am concerned with is PCEMS. This sheet has a chart for each year beginning
with 2006. I want to change the color of two rows when the workbook is
opened. This will be done via conditional formatting using VBA. The two
rows represent the current payperiod.

Within each chart are 52 weeks (ie 52 rows not counting headers, etc). I
can figure out how to locate the correct chart based on year and then
payperiod, I just need to figure out the following:

1) How to execute macro when workbook is opened?

2) What is the code to change the color for the cells?

3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Thanks,
Les

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Conditional formatting a range

Out of curiosity, when you refer to "chart", do you mean table or graph?

"WLMPilot" wrote:

This is a 3 part question. I have a workbook with several sheets. The one I
am concerned with is PCEMS. This sheet has a chart for each year beginning
with 2006. I want to change the color of two rows when the workbook is
opened. This will be done via conditional formatting using VBA. The two
rows represent the current payperiod.

Within each chart are 52 weeks (ie 52 rows not counting headers, etc). I
can figure out how to locate the correct chart based on year and then
payperiod, I just need to figure out the following:

1) How to execute macro when workbook is opened?

2) What is the code to change the color for the cells?

3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Thanks,
Les



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Conditional formatting a range

I guess chart is not the correct term to use. It is actually a spreadsheet,
not a chart derived from data. Thanks for your input. I will try them out,
but they look like what I am looking for.

Les

"JLGWhiz" wrote:

Out of curiosity, when you refer to "chart", do you mean table or graph?

"WLMPilot" wrote:

This is a 3 part question. I have a workbook with several sheets. The one I
am concerned with is PCEMS. This sheet has a chart for each year beginning
with 2006. I want to change the color of two rows when the workbook is
opened. This will be done via conditional formatting using VBA. The two
rows represent the current payperiod.

Within each chart are 52 weeks (ie 52 rows not counting headers, etc). I
can figure out how to locate the correct chart based on year and then
payperiod, I just need to figure out the following:

1) How to execute macro when workbook is opened?

2) What is the code to change the color for the cells?

3) Can an entire range be changed at once or do I have to change each cell
one at a time?

Thanks,
Les

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 with range Keyrookie Excel Worksheet Functions 2 December 3rd 09 02:20 PM
Conditional Formatting with range Keyrookie Excel Worksheet Functions 3 December 1st 09 02:22 PM
Conditional Formatting Range Donica Excel Programming 2 May 3rd 07 09:39 PM
Conditional Formatting In a Range mikesteven Excel Discussion (Misc queries) 1 July 13th 06 09:37 PM
Conditional Formatting for a Range ahishaslauer Excel Discussion (Misc queries) 2 April 3rd 06 02:29 AM


All times are GMT +1. The time now is 12:23 AM.

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"