LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Small Macro Revision - to highlight rows and enter how many times they appear in a cell rather than a msg box.

Hi
Sorry about that, my test data didn't pick it up. This one works!

Sub findtriples()


Lastrow = Cells(Rows.Count, "A").End(xlUp).Row


For RowCount = 1 To Lastrow


'Make sure data didn't appear earlier
Found = False
For OldRowCount = 1 To (RowCount - 1)
If Cells(RowCount, "A") = Cells(OldRowCount, "A") And _
Cells(RowCount, "B") = Cells(OldRowCount, "B") And _
Cells(RowCount, "C") = Cells(OldRowCount, "C") Then
Found = True
'new line here to pick up exisiting count
Cells(RowCount, "F").Value = Cells(OldRowCount, "F")
Exit For
End If
Next OldRowCount


If Found = False Then
'Count number of times combination is found
TimesFound = 1
RowsFound = CStr(RowCount)
For NewRowCount = (RowCount + 1) To Lastrow


If Cells(RowCount, "A") = Cells(NewRowCount, "A") And _
Cells(RowCount, "B") = Cells(NewRowCount, "B") And _
Cells(RowCount, "C") = Cells(NewRowCount, "C") Then


TimesFound = TimesFound + 1
RowsFound = RowsFound & "," & CStr(NewRowCount)
End If
'***********New line to pick up new counts******
Cells(RowCount, "F").Value = TimesFound
Next NewRowCount

ABCData = CStr(Cells(RowCount, "A")) & ", " & _
CStr(Cells(RowCount, "B")) & ", " & _
CStr(Cells(RowCount, "C"))
MsgBox ("Row " & CStr(RowCount) & _
" data was found " & CStr(TimesFound) & _
" time(s)" & Chr(10) & _
"Data = " & ABCData & Chr(10) & _
"Row(s) = " & RowsFound)
End If
Next RowCount
End Sub

regards
Paul
On Jun 6, 7:32 pm, "
wrote:
Hi Paul

I read your post incorrectly. I have managed to put it in the right
place now and it does everything except when it gets to the next
occurence it will then say it only found 2 when the previous occurence
says its found 3.

Does this make sense?




 
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
Macro to highlight rows and... Dave Birley Excel Programming 1 May 1st 07 01:38 PM
Number in cell appears to be 10000 times too small morris Excel Discussion (Misc queries) 1 May 6th 06 11:45 PM
Macro Revision needed HJ Excel Programming 5 May 27th 05 09:57 PM
enter a time into a cell, have the cell show two times the entry johnp Excel Worksheet Functions 3 May 2nd 05 12:08 AM
Very small macro/VBA stuff, deleting rows. Sintel Excel Programming 6 September 6th 04 05:09 PM


All times are GMT +1. The time now is 07:42 AM.

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"