PC Review


Reply
Thread Tools Rate Thread

Conditional Formatting macro: simple, but doesn't work

 
 
JP
Guest
Posts: n/a
 
      17th Feb 2010
Conditional Formatting macro: simple, but doesn't work. Using Excel 2007
with Windows 7.

Enter the number 1 in cell A1 and the number 2 in cell B1.

Start the macro recorder.
Select A1:B1.
Click Conditional Formatting, New Rule, Use a formula.
Enter: =$a1<>$a2, Format, Border, select a continuous bottom border, OK, OK.
Select cell B1 (only).
Click Conditional Formatting, New Rule, Use a formula.
Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
Stop the macro recorder.

Everything looks perfect with a line under cells A1:B1 and red font in cell
B1 (only).

Click Conditional Formatting, Clear Rules, Clear Rules from Entire Sheet.
Run the macro.
It does not implement correctly.
The incorrect result is a red font in both cells A1 and B1 rather than just
cell B1.
The text of the macro looks correct yet it insists on applying the font
color to both cells.

I tried modifying the macro, used cell ranges rather than "Selection," and
rearranged the sequence--all to no avail.

(Interestingly, if you reverse the order by first applying the conditional
font color to B1 prior to the conditional bottom border being applied to
A1:B1, the macro returns "Run-time error '1004': Unable to set the LineStyle
property of the Border class.")
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      17th Feb 2010
If a <> b then it will be red. The only way it will not be red is if a = b.
You did not specify what the cell contents were when you ran the macro.



"JP" <(E-Mail Removed)> wrote in message
news:A0541BFE-A25E-4719-A997-(E-Mail Removed)...
> Conditional Formatting macro: simple, but doesn't work. Using Excel 2007
> with Windows 7.
>
> Enter the number 1 in cell A1 and the number 2 in cell B1.
>
> Start the macro recorder.
> Select A1:B1.
> Click Conditional Formatting, New Rule, Use a formula.
> Enter: =$a1<>$a2, Format, Border, select a continuous bottom border, OK,
> OK.
> Select cell B1 (only).
> Click Conditional Formatting, New Rule, Use a formula.
> Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
> Stop the macro recorder.
>
> Everything looks perfect with a line under cells A1:B1 and red font in
> cell
> B1 (only).
>
> Click Conditional Formatting, Clear Rules, Clear Rules from Entire Sheet.
> Run the macro.
> It does not implement correctly.
> The incorrect result is a red font in both cells A1 and B1 rather than
> just
> cell B1.
> The text of the macro looks correct yet it insists on applying the font
> color to both cells.
>
> I tried modifying the macro, used cell ranges rather than "Selection," and
> rearranged the sequence--all to no avail.
>
> (Interestingly, if you reverse the order by first applying the conditional
> font color to B1 prior to the conditional bottom border being applied to
> A1:B1, the macro returns "Run-time error '1004': Unable to set the
> LineStyle
> property of the Border class.")



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      17th Feb 2010
Sorry. should have been if A1 <> a2 then it will be red.


"JP" <(E-Mail Removed)> wrote in message
news:A0541BFE-A25E-4719-A997-(E-Mail Removed)...
> Conditional Formatting macro: simple, but doesn't work. Using Excel 2007
> with Windows 7.
>
> Enter the number 1 in cell A1 and the number 2 in cell B1.
>
> Start the macro recorder.
> Select A1:B1.
> Click Conditional Formatting, New Rule, Use a formula.
> Enter: =$a1<>$a2, Format, Border, select a continuous bottom border, OK,
> OK.
> Select cell B1 (only).
> Click Conditional Formatting, New Rule, Use a formula.
> Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
> Stop the macro recorder.
>
> Everything looks perfect with a line under cells A1:B1 and red font in
> cell
> B1 (only).
>
> Click Conditional Formatting, Clear Rules, Clear Rules from Entire Sheet.
> Run the macro.
> It does not implement correctly.
> The incorrect result is a red font in both cells A1 and B1 rather than
> just
> cell B1.
> The text of the macro looks correct yet it insists on applying the font
> color to both cells.
>
> I tried modifying the macro, used cell ranges rather than "Selection," and
> rearranged the sequence--all to no avail.
>
> (Interestingly, if you reverse the order by first applying the conditional
> font color to B1 prior to the conditional bottom border being applied to
> A1:B1, the macro returns "Run-time error '1004': Unable to set the
> LineStyle
> property of the Border class.")



 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      17th Feb 2010
The cell contents were in fact stated in the original post as, "Enter the
number 1 in cell A1 and the number 2 in cell B1."

"JLGWhiz" wrote:

> If a <> b then it will be red. The only way it will not be red is if a = b.
> You did not specify what the cell contents were when you ran the macro.
>
>
>
> "JP" <(E-Mail Removed)> wrote in message
> news:A0541BFE-A25E-4719-A997-(E-Mail Removed)...
> > Conditional Formatting macro: simple, but doesn't work. Using Excel 2007
> > with Windows 7.
> >
> > Enter the number 1 in cell A1 and the number 2 in cell B1.
> >
> > Start the macro recorder.
> > Select A1:B1.
> > Click Conditional Formatting, New Rule, Use a formula.
> > Enter: =$a1<>$a2, Format, Border, select a continuous bottom border, OK,
> > OK.
> > Select cell B1 (only).
> > Click Conditional Formatting, New Rule, Use a formula.
> > Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
> > Stop the macro recorder.
> >
> > Everything looks perfect with a line under cells A1:B1 and red font in
> > cell
> > B1 (only).
> >
> > Click Conditional Formatting, Clear Rules, Clear Rules from Entire Sheet.
> > Run the macro.
> > It does not implement correctly.
> > The incorrect result is a red font in both cells A1 and B1 rather than
> > just
> > cell B1.
> > The text of the macro looks correct yet it insists on applying the font
> > color to both cells.
> >
> > I tried modifying the macro, used cell ranges rather than "Selection," and
> > rearranged the sequence--all to no avail.
> >
> > (Interestingly, if you reverse the order by first applying the conditional
> > font color to B1 prior to the conditional bottom border being applied to
> > A1:B1, the macro returns "Run-time error '1004': Unable to set the
> > LineStyle
> > property of the Border class.")

>
>
> .
>

 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      17th Feb 2010
As previously stated, the formula that needs to be entered is: =$a1<>$a2,
not "A1 <> a2."
If the steps in the original post are followed precisely you'll see what I
mean.
Thanks for replying.


"JLGWhiz" wrote:

> Sorry. should have been if A1 <> a2 then it will be red.
>
>
> "JP" <(E-Mail Removed)> wrote in message
> news:A0541BFE-A25E-4719-A997-(E-Mail Removed)...
> > Conditional Formatting macro: simple, but doesn't work. Using Excel 2007
> > with Windows 7.
> >
> > Enter the number 1 in cell A1 and the number 2 in cell B1.
> >
> > Start the macro recorder.
> > Select A1:B1.
> > Click Conditional Formatting, New Rule, Use a formula.
> > Enter: =$a1<>$a2, Format, Border, select a continuous bottom border, OK,
> > OK.
> > Select cell B1 (only).
> > Click Conditional Formatting, New Rule, Use a formula.
> > Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
> > Stop the macro recorder.
> >
> > Everything looks perfect with a line under cells A1:B1 and red font in
> > cell
> > B1 (only).
> >
> > Click Conditional Formatting, Clear Rules, Clear Rules from Entire Sheet.
> > Run the macro.
> > It does not implement correctly.
> > The incorrect result is a red font in both cells A1 and B1 rather than
> > just
> > cell B1.
> > The text of the macro looks correct yet it insists on applying the font
> > color to both cells.
> >
> > I tried modifying the macro, used cell ranges rather than "Selection," and
> > rearranged the sequence--all to no avail.
> >
> > (Interestingly, if you reverse the order by first applying the conditional
> > font color to B1 prior to the conditional bottom border being applied to
> > A1:B1, the macro returns "Run-time error '1004': Unable to set the
> > LineStyle
> > property of the Border class.")

>
>
> .
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      17th Feb 2010
I did try it after I had posted the reply and it looks like it does not like
the overlap on the first condition for some reason. I have not spent a lot
of time on Conditional Format so I won't be any help to you on this one.


"JP" <(E-Mail Removed)> wrote in message
news:407E8214-4F23-42AA-BB45-(E-Mail Removed)...
> As previously stated, the formula that needs to be entered is: =$a1<>$a2,
> not "A1 <> a2."
> If the steps in the original post are followed precisely you'll see what I
> mean.
> Thanks for replying.
>
>
> "JLGWhiz" wrote:
>
>> Sorry. should have been if A1 <> a2 then it will be red.
>>
>>
>> "JP" <(E-Mail Removed)> wrote in message
>> news:A0541BFE-A25E-4719-A997-(E-Mail Removed)...
>> > Conditional Formatting macro: simple, but doesn't work. Using Excel
>> > 2007
>> > with Windows 7.
>> >
>> > Enter the number 1 in cell A1 and the number 2 in cell B1.
>> >
>> > Start the macro recorder.
>> > Select A1:B1.
>> > Click Conditional Formatting, New Rule, Use a formula.
>> > Enter: =$a1<>$a2, Format, Border, select a continuous bottom border,
>> > OK,
>> > OK.
>> > Select cell B1 (only).
>> > Click Conditional Formatting, New Rule, Use a formula.
>> > Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
>> > Stop the macro recorder.
>> >
>> > Everything looks perfect with a line under cells A1:B1 and red font in
>> > cell
>> > B1 (only).
>> >
>> > Click Conditional Formatting, Clear Rules, Clear Rules from Entire
>> > Sheet.
>> > Run the macro.
>> > It does not implement correctly.
>> > The incorrect result is a red font in both cells A1 and B1 rather than
>> > just
>> > cell B1.
>> > The text of the macro looks correct yet it insists on applying the font
>> > color to both cells.
>> >
>> > I tried modifying the macro, used cell ranges rather than "Selection,"
>> > and
>> > rearranged the sequence--all to no avail.
>> >
>> > (Interestingly, if you reverse the order by first applying the
>> > conditional
>> > font color to B1 prior to the conditional bottom border being applied
>> > to
>> > A1:B1, the macro returns "Run-time error '1004': Unable to set the
>> > LineStyle
>> > property of the Border class.")

>>
>>
>> .
>>



 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      18th Feb 2010
Thanks, JLG, for trying. Your efforts are appreciated. This one may have to
remain unresolved.
Best regards,
JP

"JLGWhiz" wrote:

> I did try it after I had posted the reply and it looks like it does not like
> the overlap on the first condition for some reason. I have not spent a lot
> of time on Conditional Format so I won't be any help to you on this one.
>
>
> "JP" <(E-Mail Removed)> wrote in message
> news:407E8214-4F23-42AA-BB45-(E-Mail Removed)...
> > As previously stated, the formula that needs to be entered is: =$a1<>$a2,
> > not "A1 <> a2."
> > If the steps in the original post are followed precisely you'll see what I
> > mean.
> > Thanks for replying.
> >
> >
> > "JLGWhiz" wrote:
> >
> >> Sorry. should have been if A1 <> a2 then it will be red.
> >>
> >>
> >> "JP" <(E-Mail Removed)> wrote in message
> >> news:A0541BFE-A25E-4719-A997-(E-Mail Removed)...
> >> > Conditional Formatting macro: simple, but doesn't work. Using Excel
> >> > 2007
> >> > with Windows 7.
> >> >
> >> > Enter the number 1 in cell A1 and the number 2 in cell B1.
> >> >
> >> > Start the macro recorder.
> >> > Select A1:B1.
> >> > Click Conditional Formatting, New Rule, Use a formula.
> >> > Enter: =$a1<>$a2, Format, Border, select a continuous bottom border,
> >> > OK,
> >> > OK.
> >> > Select cell B1 (only).
> >> > Click Conditional Formatting, New Rule, Use a formula.
> >> > Enter: =B1<>C1, Format, Font, Color, select red, OK, OK.
> >> > Stop the macro recorder.
> >> >
> >> > Everything looks perfect with a line under cells A1:B1 and red font in
> >> > cell
> >> > B1 (only).
> >> >
> >> > Click Conditional Formatting, Clear Rules, Clear Rules from Entire
> >> > Sheet.
> >> > Run the macro.
> >> > It does not implement correctly.
> >> > The incorrect result is a red font in both cells A1 and B1 rather than
> >> > just
> >> > cell B1.
> >> > The text of the macro looks correct yet it insists on applying the font
> >> > color to both cells.
> >> >
> >> > I tried modifying the macro, used cell ranges rather than "Selection,"
> >> > and
> >> > rearranged the sequence--all to no avail.
> >> >
> >> > (Interestingly, if you reverse the order by first applying the
> >> > conditional
> >> > font color to B1 prior to the conditional bottom border being applied
> >> > to
> >> > A1:B1, the macro returns "Run-time error '1004': Unable to set the
> >> > LineStyle
> >> > property of the Border class.")
> >>
> >>
> >> .
> >>

>
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting - Worked - Bad - Doesn't Work Victor Microsoft Access Form Coding 6 14th May 2010 11:26 PM
Conditional formatting - why doesn't this work? DDawson Microsoft Excel Programming 3 7th Oct 2008 11:42 AM
SIMPLE VBA MACRO FOR CONDITIONAL FORMATTING =?Utf-8?B?RkFSQVogUVVSRVNISQ==?= Microsoft Excel Misc 4 31st Jul 2007 12:10 PM
Why doesn't my simple macro work? Tibbs Microsoft Excel Programming 5 1st Mar 2006 02:56 PM
Why this simple macro doesn't work? 71marco71 Microsoft Excel Programming 2 6th Feb 2004 06:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 AM.