Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compare two col to same two on next row

There are numbers in col B and words in col G.
I need to compare Col B and Col G (together) to the same two columns o
the next row for all rows. I need to count every time there is
repeat but i don't want to count the first occurance just from th
second on. Each time the word in column G changes I need to start
new count. I would like to record the totals for each new word in co
G, in a new cell. For example for the first word I record the tota
number of repeats in cell H1, for the second word I record the numbe
of repeats in H2 and so on. Is this possible. If I have to d
something else with the totals that is ok. I have attached a smal
example of a spread sheet so you can visualize this.


Thank you for your help

Morr

Attachment filename: sample.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=58370
--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Compare two col to same two on next row

Hi
try
=SUMPRODUCT(--(B1:B99=B2:B100),--(G1:G99=G2:G100))

--
Regards
Frank Kabel
Frankfurt, Germany


There are numbers in col B and words in col G.
I need to compare Col B and Col G (together) to the same two columns
on the next row for all rows. I need to count every time there is a
repeat but i don't want to count the first occurance just from the
second on. Each time the word in column G changes I need to start a
new count. I would like to record the totals for each new word in

col
G, in a new cell. For example for the first word I record the total
number of repeats in cell H1, for the second word I record the number
of repeats in H2 and so on. Is this possible. If I have to do
something else with the totals that is ok. I have attached a small
example of a spread sheet so you can visualize this.


Thank you for your help

Morry

Attachment filename: sample.xls
Download attachment:
http://www.excelforum.com/attachment.php?postid=583708 ---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compare two col to same two on next row

Morry

I have not looked at your attached sample sheet as I do not open unkow
files.


If I understand your problem correctly this should do what you want


Sub CountDup()
Dim iCnt As Integer
Dim lRow As Long
Dim sWord As String

For lRow = 1 To Cells.Find(what:="*", _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row Step 1

If Cells(lRow, "g").Value = sWord Then
If Cells(lRow, "b").Value = _
Cells(lRow + 1, "b").Value Then
iCnt = iCnt + 1
End If

Else
Cells(Range("h" & Rows.Count).End(xlUp).Row + 1, _
"h").Value = sWord & " " & iCnt - 1

iCnt = 0
sWord$ = Cells(lRow, "g")
End If
Nex

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compare two col to same two on next row

Thank you Frank for the feedback but that wasn't exactly what I wa
looking for but thanks anyway.

Mudraker, what you gave me is really close but it still isn't exactl
what I need. I tried to modify your code to make it work but I stil
could not return what I need exactly.

I understand why you don't want to open unknown files, I don't either.
I will list below a small sample of my spreadsheet.

Col B Col G

826 TaskA
826 TaskA 1
867 TaskA
895 TaskA
967 TaskA
967 TaskA 1
969 TaskA
969 TaskA 1
1010 TaskA
1030 TaskA
1031 TaskA
1049 TaskC
1049 TaskB
1050 TaskB
1052 TaskB
1052 TaskB 2
1052 TaskB 2
1059 TaskB
1062 TaskC
1062 TaskB
1062 TaskB 2
1062 TaskA
1063 TaskC
1063 TaskC 3
1063 TaskB
1063 TaskB 2

Here is an example
Task A = 3
Task B = 4
Task C = 1

We don't count the first one but if the next one matches then we coun
it and then it gives one total for each individual task.

Can you help me figure this out?

Thank you very much

Morr

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compare two col to same two on next row

Morry

Hopefully I understand your problem correctly

This version puts the text of column G into column H

If I have done it correctly it would then only require counting eac
time each item is listed.

I did not want to add any more code in case I still have not this firs
part right


Sub CountDup2()
Dim lRow As Long

For lRow = 1 To Cells.Find(what:="*", _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row Step 1

If Cells(lRow, "b").Value = _
Cells(lRow + 1, "b").Value Then
If Cells(lRow, "g").Value = _
Cells(lRow + 1, "g").Value Then
Range("h" & lRow + 1).Value = Cells(lRow, "g").Value
End If
End If
Next
End Su

--
Message posted from http://www.ExcelForum.com

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
COMPARE Add-in pwrichcreek Excel Discussion (Misc queries) 1 August 20th 08 08:58 PM
Compare Srenfro Excel Worksheet Functions 1 March 11th 08 10:02 PM
How do I compare cells and if FALSE compare to next cell in EXCEL Cindie Excel Worksheet Functions 0 March 24th 06 05:29 PM
compare rjtaylor[_3_] Excel Programming 3 February 13th 04 04:50 AM
compare data from one column with another and compare result to yet another Matt Williamson[_3_] Excel Programming 1 September 25th 03 08:54 PM


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