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: 13
Default Formula or code

Try this

Sub Macro1()
Dim NameLp As Integer
Dim SearchLp As Integer
Dim ResltLp As Integer
Dim NameCnt As Integer
Dim ResltCnt As Integer
Dim ResltPntr As Integer
Dim LastRow As Integer
Dim FirstRow As Integer
Dim SearchName As String
Dim SearchCnt As Integer

'set range
FirstRow = 1
LastRow = ActiveSheet.UsedRange.Rows.Count
ResltCnt = 0
If LastRow <= FirstRow Then Exit Sub
'Copy name list to new column
'Columns("A:A").Copy
'Columns("D:D").PasteSpecial
'Application.CutCopyMode = False
'Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

'Assuming names are in column "A", search for matches
For NameLp = FirstRow To LastRow
NameCnt = 0
ResltPntr = 0
SearchName = Range("A" & NameLp).Value
If ResltCnt = 0 Then
ResltCnt = ResltCnt + 1
Range("D" & ResltCnt).Value = SearchName
ResltPntr = 1
Else
For ResltLp = 1 To ResltCnt
If Range("D" & ResltLp).Value = SearchName Then
ResltPntr = ResltLp 'name in results already
Exit For
End If
Next ResltLp
If ResltPntr = 0 Then 'name not in results
ResltCnt = ResltCnt + 1
ResltPntr = ResltCnt
Range("D" & ResltPntr).Value = SearchName
End If
End If
For SearchLp = FirstRow To LastRow
If Range("A" & SearchLp).Value = SearchName Then
'using column "D" + "E" for temp results
NameCnt = NameCnt + 1
Range("E" & ResltPntr).Value = NameCnt
End If
Next SearchLp
Next NameLp
'Write back matches
For ResltLp = 1 To ResltCnt
For NameLp = FirstRow To LastRow
If Range("D" & ResltLp).Value = Range("A" & NameLp).Value Then
Range("B" & NameLp).Value = Range("E" & ResltLp).Value
End If
Next NameLp
Next ResltLp
End Sub

Hope it helps
"Gordon Cartwright" wrote in message
...
Hi...

In colum A I have 3000 names. In column B I want to
indicate which of these names are repeated in the adjacant
B cell. The value in colum B must be the number of times
the name has been repeated...eg

A B
Jones 4
Jones 4
Jones 4
Harris
Smith 2
Smith 2
Jackson
Jones 4

Vlookup and Hlookup tables just don't seem to do the job.
Can anyone help here?

Thanks in advance

Gordon Cartwright



 
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
How to code the formula? Eric Excel Discussion (Misc queries) 5 June 24th 09 04:41 PM
copy formula using VB code ASU Excel Discussion (Misc queries) 2 September 7th 06 09:09 PM
formula or vba code Nader Excel Worksheet Functions 14 August 16th 06 10:54 AM
formula code nobbyknownowt Excel Discussion (Misc queries) 5 August 10th 06 05:40 PM
formula or code Monty Excel Worksheet Functions 10 January 10th 05 09:06 AM


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