Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default turns it all red, not just if boolean is true -- help with macro

Okay.
c, rbn, rbo and rnbo are ranges. DupsFound is boolean. The logic is if
this cell is this workbook on this sheet in this range (see ranges above)
equals the value of this cell in this workbook on this sheet in this range
(again see above) then set the boolean to true and color the cell red.
Any ideas why the entire column turns red?
First, here is an example of my declared ranges:
temp1 = InputBox("What is the name of the new Demand Workbook?")
Set BANew = Workbooks(temp1 & ".xls").Sheets(1)
t1 = BANew.Cells(Rows.Count, 1).End(xlUp).Row
Set rbn = BANew.Range(BANew.Cells(3, 1), BANew.Cells(t1, 1).End(xlDown))

Then here is where I check for duplicates between workbook and different
worksheets within those workbook:

For Each c In rbn.Cells
If Application.CountIf(rbo, c.Value) 0 Then _
DupsFound = True
c.Interior.ColorIndex = 3
If Application.CountIf(rnbo, c.Value) 0 Then _
DupsFound = True
c.Interior.ColorIndex = 3
Next

If you need clarification just let me know:
Nicole
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default turns it all red, not just if boolean is true -- help with macro

Your problem is that you IF statement are screwed up:

For Each c In rbn.Cells
If Application.CountIf(rbo, c.Value) 0 Then
DupsFound = True
c.Interior.ColorIndex = 3
End if
If Application.CountIf(rnbo, c.Value) 0 Then
DupsFound = True
c.Interior.ColorIndex = 3
End if
Next

--
Regards,
Tom Ogilvy
"Nicole Seibert" wrote:

Okay.
c, rbn, rbo and rnbo are ranges. DupsFound is boolean. The logic is if
this cell is this workbook on this sheet in this range (see ranges above)
equals the value of this cell in this workbook on this sheet in this range
(again see above) then set the boolean to true and color the cell red.
Any ideas why the entire column turns red?
First, here is an example of my declared ranges:
temp1 = InputBox("What is the name of the new Demand Workbook?")
Set BANew = Workbooks(temp1 & ".xls").Sheets(1)
t1 = BANew.Cells(Rows.Count, 1).End(xlUp).Row
Set rbn = BANew.Range(BANew.Cells(3, 1), BANew.Cells(t1, 1).End(xlDown))

Then here is where I check for duplicates between workbook and different
worksheets within those workbook:

For Each c In rbn.Cells
If Application.CountIf(rbo, c.Value) 0 Then _
DupsFound = True
c.Interior.ColorIndex = 3
If Application.CountIf(rnbo, c.Value) 0 Then _
DupsFound = True
c.Interior.ColorIndex = 3
Next

If you need clarification just let me know:
Nicole

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
convert Boolean true-false to zero's and ones Vivek Excel Discussion (Misc queries) 8 November 16th 07 08:18 PM
TRUE - Boolean vs. Text Epinn Excel Worksheet Functions 11 November 19th 06 09:12 AM
Boolean 0/1 instead of True/False Tony Excel Discussion (Misc queries) 10 May 29th 06 04:14 AM
how can I insert a macro into a boolean statement Garrett Excel Worksheet Functions 1 December 29th 05 03:46 PM
using macro IE turns error... bduzenli Excel Programming 1 May 3rd 04 04:16 PM


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