LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Count function for two specific items in vba

I have a macro that compares two columns of data and puts either "OK" or
"Name in Col B is not in Col A" in the third column. Then it compares Col A
with Col B and does the same thing by placing the "OK" or "Name in Col A is
not in Col B" in the fourth column. Column A and Column B will have
different rows of data also. My data will be different on a daily basis so
I do not know where the last row of data will be. After the first macro has
run, I would like to place a count function on the last cell in column C and
also in column D to count the "OK"'s and also the "Names....". Can someone
please help me with this.

Here is what I have so far.

Sub compare()
Range("a1").Select
While Not IsEmpty(ActiveCell)
If WorksheetFunction.CountIf(Range("b:b"), ActiveCell) 0 Then
ActiveCell.Offset(0, 3) = "OK"
Else
ActiveCell.Offset(0, 3) = "Name in Col A is not in Col B"
End If
ActiveCell.Offset(1, 0).Select
Wend
Range("b1").Select
While Not IsEmpty(ActiveCell)
If WorksheetFunction.CountIf(Range("a:a"), ActiveCell) 0 Then
ActiveCell.Offset(0, 1) = "OK"
Else
ActiveCell.Offset(0, 1) = "Name in Col B is not in Col A"
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub

--
Thanks,
Cynthia G.

"Information is just signs and numbers, while knowledge
involves their meaning. What we want is knowledge, but what
we get is information."
--Heinz R. Pagels


 
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
Formula to count month-specific items IoHeFy Excel Discussion (Misc queries) 4 January 4th 07 01:45 PM
Count items when specific text and date criteria are met javamom Excel Worksheet Functions 8 April 24th 06 09:28 PM
Function to count unique items in list XP Excel Worksheet Functions 2 April 10th 06 06:30 PM
Function to Count Number of Consecutive Rows with a Specific Criteria? Templee1 Excel Worksheet Functions 2 July 10th 05 10:22 PM
Count items between specific hours on a matching date KS Excel Worksheet Functions 1 December 10th 04 05:52 PM


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