 |
|
 |
|
Next: can we navigate powerpoint using bluetooth mobile
|
| Author |
Message |
External

Since: Feb 8, 2009 Posts: 11
|
(Msg. 16) Posted: Sun Dec 06, 2009 1:38 pm
Post subject: Re: copy conditional formats Archived from groups: microsoft>public>excel (more info?)
|
|
|
|
| Bernie, I have had some medical issues and I just got back to the macro
today. It looks like it will run OK. I conditionally “format is” some of
the cells (but not all) in column C. When I step through the code, it
formats (fills) every cell in R2, even if the cell in column C does not meet
the format criteria. I think I will be able to work this out. Thank you
very much for the help.
|
>> Stay informed about: copy conditional formats |
|
| Back to top |
|
 |  |
External

Since: Feb 8, 2009 Posts: 11
|
(Msg. 17) Posted: Mon Dec 07, 2009 1:01 pm
Post subject: RE: copy conditional formats Archived from groups: per prev. post (more info?)
|
|
|
Bernie, I still cannot get the macro to work properly. There are 2 rows in
column C. Both cells are conditionally formatted based on the equation
“A1-B1”. If A>B, then fill the cell yellow. If A1<B1, do not fill any
color. In this case, C1 is yellow (meets the format condition), and C2 is
blank (does not meet the format condition). When I step through the code you
suggested, the command line
bCheck = Application.Evaluate(c.FormatConditions.Item(i).Formula1)
formats both C1 and C2 yellow. It is as if the command line only checks to
see if there is ANY conditional formatting (Type 2 condition), and if there
is, it fills the cell. I am trying to duplicate the fill color (including no
fill), but eliminate the conditional format equations. I have tried running
macros that just get the colorindex, but they don’t work with conditionally
formatted cells. Would appreciate any ideas. >> Stay informed about: copy conditional formats |
|
| Back to top |
|
 |  |
External

Since: Feb 8, 2009 Posts: 11
|
(Msg. 18) Posted: Mon Dec 07, 2009 4:22 pm
Post subject: RE: copy conditional formats Archived from groups: per prev. post (more info?)
|
|
|
I thought it might help if I showed you the abridged code:
Option Explicit
Dim R1 As Range
Dim R2 As Range
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Sel As Range
Dim myRet As Variant
Dim bCheck As Boolean
Sub CopyCFFormatsA()
Set Sel = Selection
Set R1 = Range("c1:c10")
Set R2 = Range("d1:d10")
j = 1
Application.EnableEvents = False
For i = 1 To R1.Rows.Count
R1.Cells(i, j).Select
myRet = CheckFormat(R1.Cells(i, j))
If myRet = False Then GoTo NoCF
If myRet = "None" Then GoTo NoCF
R2.Cells(i, j).Interior.colorindex = _
R1.Cells(i, j).FormatConditions(myRet).Interior.colorindex
NoCF:
Next i
Sel.Select
Application.EnableEvents = True
End Sub
Function CheckFormat(c As Range) As Variant
CheckFormat = "None"
For k = 1 To c.FormatConditions.Count
bCheck = Application.Evaluate(c.FormatConditions.Item(k).Formula1)
If bCheck Then
CheckFormat = k
bCheck = False
Exit Function
End If
Next k
CheckFormat = "None"
End Function--
Bill Roberts
"Bill Roberts" wrote:
> Bernie, I still cannot get the macro to work properly. There are 2 rows in
> column C. Both cells are conditionally formatted based on the equation
> “A1-B1”. If A>B, then fill the cell yellow. If A1<B1, do not fill any
> color. In this case, C1 is yellow (meets the format condition), and C2 is
> blank (does not meet the format condition). When I step through the code you
> suggested, the command line
> bCheck = Application.Evaluate(c.FormatConditions.Item(i).Formula1)
> formats both C1 and C2 yellow. It is as if the command line only checks to
> see if there is ANY conditional formatting (Type 2 condition), and if there
> is, it fills the cell. I am trying to duplicate the fill color (including no
> fill), but eliminate the conditional format equations. I have tried running
> macros that just get the colorindex, but they don’t work with conditionally
> formatted cells. Would appreciate any ideas.
>
> --
> Bill Roberts
>
>
> "Bill Roberts" wrote:
>
> > I have a column that has been conditionally formatted with equations, using
> > the "fill" command to color the cells based on the relative values of cells
> > in other columns. I want to copy only the colors to another column, but not
> > the equations. As if I would do a copy/paste special/values, but the
> > conditionally formatting equations refuse to go away. I just want only the
> > color patterns in the new column. Would appreciate any suggestions. TIA
> > Bill Roberts >> Stay informed about: copy conditional formats |
|
| Back to top |
|
 |  |
External

Since: Dec 17, 2008 Posts: 10
|
(Msg. 19) Posted: Mon Dec 07, 2009 5:21 pm
Post subject: Re: copy conditional formats Archived from groups: per prev. post (more info?)
|
|
|
Bill,
Did you leave in the line?
R1.Cells(i, j).Select
Excel evaluated CF formulas as if it were copied into the currently selected
cell - so if the selection doesn't change, the formula evaluates to only one
value.
Bernie
"Bill Roberts" wrote in message
> Bernie, I still cannot get the macro to work properly. There are 2 rows
> in
> column C. Both cells are conditionally formatted based on the equation
> “A1-B1”. If A>B, then fill the cell yellow. If A1<B1, do not fill any
> color. In this case, C1 is yellow (meets the format condition), and C2 is
> blank (does not meet the format condition). When I step through the code
> you
> suggested, the command line
> bCheck = Application.Evaluate(c.FormatConditions.Item(i).Formula1)
> formats both C1 and C2 yellow. It is as if the command line only checks
> to
> see if there is ANY conditional formatting (Type 2 condition), and if
> there
> is, it fills the cell. I am trying to duplicate the fill color (including
> no
> fill), but eliminate the conditional format equations. I have tried
> running
> macros that just get the colorindex, but they don’t work with
> conditionally
> formatted cells. Would appreciate any ideas.
>
> --
> Bill Roberts
>
>
> "Bill Roberts" wrote:
>
>> I have a column that has been conditionally formatted with equations,
>> using
>> the "fill" command to color the cells based on the relative values of
>> cells
>> in other columns. I want to copy only the colors to another column, but
>> not
>> the equations. As if I would do a copy/paste special/values, but the
>> conditionally formatting equations refuse to go away. I just want only
>> the
>> color patterns in the new column. Would appreciate any suggestions. TIA
>> Bill Roberts >> Stay informed about: copy conditional formats |
|
| Back to top |
|
 |  |
External

Since: Dec 17, 2008 Posts: 10
|
(Msg. 20) Posted: Mon Dec 07, 2009 10:15 pm
Post subject: Re: copy conditional formats Archived from groups: per prev. post (more info?)
|
|
|
Bill,
Your version of the code worked perfectly, but I'm testing it in XL 2003. I
will have to try to locate a machine with XL2007 to try it out on, and I
will post back in the morning.
Bernie
"Bill Roberts" wrote in message
>I thought it might help if I showed you the abridged code:
>
> Option Explicit
> Dim R1 As Range
> Dim R2 As Range
> Dim i As Integer
> Dim j As Integer
> Dim k As Integer
> Dim Sel As Range
> Dim myRet As Variant
> Dim bCheck As Boolean
> Sub CopyCFFormatsA()
> Set Sel = Selection
> Set R1 = Range("c1:c10")
> Set R2 = Range("d1:d10")
> j = 1
> Application.EnableEvents = False
> For i = 1 To R1.Rows.Count
> R1.Cells(i, j).Select
> myRet = CheckFormat(R1.Cells(i, j))
> If myRet = False Then GoTo NoCF
> If myRet = "None" Then GoTo NoCF
> R2.Cells(i, j).Interior.colorindex = _
> R1.Cells(i, j).FormatConditions(myRet).Interior.colorindex
> NoCF:
> Next i
> Sel.Select
> Application.EnableEvents = True
> End Sub
> Function CheckFormat(c As Range) As Variant
> CheckFormat = "None"
> For k = 1 To c.FormatConditions.Count
> bCheck = Application.Evaluate(c.FormatConditions.Item(k).Formula1)
> If bCheck Then
> CheckFormat = k
> bCheck = False
> Exit Function
> End If
> Next k
> CheckFormat = "None"
> End Function--
> Bill Roberts
>
>
> "Bill Roberts" wrote:
>
>> Bernie, I still cannot get the macro to work properly. There are 2 rows
>> in
>> column C. Both cells are conditionally formatted based on the equation
>> “A1-B1”. If A>B, then fill the cell yellow. If A1<B1, do not fill any
>> color. In this case, C1 is yellow (meets the format condition), and C2
>> is
>> blank (does not meet the format condition). When I step through the code
>> you
>> suggested, the command line
>> bCheck = Application.Evaluate(c.FormatConditions.Item(i).Formula1)
>> formats both C1 and C2 yellow. It is as if the command line only checks
>> to
>> see if there is ANY conditional formatting (Type 2 condition), and if
>> there
>> is, it fills the cell. I am trying to duplicate the fill color
>> (including no
>> fill), but eliminate the conditional format equations. I have tried
>> running
>> macros that just get the colorindex, but they don’t work with
>> conditionally
>> formatted cells. Would appreciate any ideas.
>>
>> --
>> Bill Roberts
>>
>>
>> "Bill Roberts" wrote:
>>
>> > I have a column that has been conditionally formatted with equations,
>> > using
>> > the "fill" command to color the cells based on the relative values of
>> > cells
>> > in other columns. I want to copy only the colors to another column,
>> > but not
>> > the equations. As if I would do a copy/paste special/values, but the
>> > conditionally formatting equations refuse to go away. I just want
>> > only the
>> > color patterns in the new column. Would appreciate any suggestions.
>> > TIA
>> > Bill Roberts >> Stay informed about: copy conditional formats |
|
| Back to top |
|
 |  |
| Related Topics: | Conditional formatting - I want to change font when a cell takes a certain value from a formula, but in the conditional formatting box the font selection is ghosted out. Any tips on how I can do this?
Conditional Formating - I have an Excel spreadsheet that has C3=4, C4=3, & C5=2 and I want to do contitional formating for another cell to have an arrow showing a direction based on C3 - C5 (e.g., if B3>C3 arrow up, if B3=C4 nothing, if B3<C5 arrow down). Is there...
Conditional formatting - I seem to have problems writing formulas for conditional formatting. H J K 5 98 103 I want to write a rule such that if K117 is greater than j117 and also if H 117>0, then the cell turns yellow or whatever. Can't get it to work. Thanks
copy/paste macro - I am trying to create a macro that will copy a range of data; however, the number of rows to copy will vary each time the macro is run. Is there a way that I could creat parameter fields that the macro cuold read? Thanks, Micki
Copy cells with value 0 as a list - Hi, I have a sheet with some cells with value 0 and others with data. I want a macro that copies all the cells with value <>0 in other sheet but as a list, one under the other. Is this possible? Thanks! |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|