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: 23
Default Reg:Macro needed to pick up only distinct values but it picks up allthe values

Hi all,
I have used the following code to lookup values for ID in
colB and for that value gives all the values of the WRnbr in colC ,
but I need the code to return only distinct values for the WR#,please
advise of the modifications.ANy help would be appreciated:

Option Explicit
Sub FindWRNbr()
Dim ws1 As Worksheet, ws2 As Worksheet, a As Long, SPMID As String
Dim c As Range, firstaddress As String, Hold As String
Set ws1 = Sheets("SPM_id_view")
Set ws2 = Sheets("Dragoni_owned")
Application.ScreenUpdating = False
With ws1
For a = 2 To .Cells(Rows.Count, 2).End(xlUp).Row Step 1
Hold = ""
SPMID = .Cells(a, 2).Value
With ws2.Columns(34)

Set c = .Find(SPMID, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
firstaddress = c.Address
Do
Hold = Hold & c.Offset(, -33).Value & "#"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
End With
If Right(Hold, 1) = "#" Then
Hold = Left(Hold, Len(Hold) - 1)
ws1.Cells(a, 3) = Hold
End If
Next a
End With
Application.ScreenUpdating = True
ws1.Select
End Sub
 
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
when i pick a cell, it picks cells below also, how do i stop this cindu Excel Worksheet Functions 2 June 2nd 09 11:23 PM
How do I get the distinct values in a column & put it in next col VIDYA Excel Discussion (Misc queries) 2 December 22nd 08 06:28 PM
how to count distinct values???/ rishi Excel Programming 2 May 10th 07 03:29 PM
Counting Distinct Values giantwolf Excel Discussion (Misc queries) 4 December 29th 05 03:03 PM
Count Distinct Values? bill_morgan Excel Worksheet Functions 7 April 27th 05 02:12 AM


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