ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with three columns find unique data (https://www.excelbanter.com/excel-programming/367178-help-three-columns-find-unique-data.html)

ColB[_2_]

Help with three columns find unique data
 

Okay,

I have three columns, A B C

A holds multiple occurrences of once appearing data in B.

eg

A B C

10
10
10
10 10 5
11
11
11
11 11 6


I need a script that will read A, find that value in B and paste
corresponding C value in D.

So for the above example D would be

5
5
5
5
6
6
6
6


I don't know where to even start.

HELP!


--
ColB
------------------------------------------------------------------------
ColB's Profile: http://www.excelforum.com/member.php...o&userid=36350
View this thread: http://www.excelforum.com/showthread...hreadid=561356


Greg Wilson

Help with three columns find unique data
 
This is one interpretation. Minimal testing.

Sub Test123()
Dim c As Range, cc As Range
Dim r As Range
Dim ws As Worksheet
Dim v As Integer 'change data type to suit

Set ws = ActiveSheet
Set r = ws.Columns(2).SpecialCells(xlCellTypeConstants)
For Each c In r.Cells
If IsNumeric(c.Value) Then
v = c(1, 2)
Set cc = c(1, 0)
Do Until cc.Value < c.Value
cc(1, 4) = v
If cc.Row = 1 Then Exit Do
Set cc = cc(0)
Loop
End If
Next
End Sub

Regards,
Greg

"ColB" wrote:


Okay,

I have three columns, A B C

A holds multiple occurrences of once appearing data in B.

eg

A B C

10
10
10
10 10 5
11
11
11
11 11 6


I need a script that will read A, find that value in B and paste
corresponding C value in D.

So for the above example D would be

5
5
5
5
6
6
6
6


I don't know where to even start.

HELP!


--
ColB
------------------------------------------------------------------------
ColB's Profile: http://www.excelforum.com/member.php...o&userid=36350
View this thread: http://www.excelforum.com/showthread...hreadid=561356



ColB[_3_]

Help with three columns find unique data
 

Thanks Greg, worked like a charm.


--
ColB
------------------------------------------------------------------------
ColB's Profile: http://www.excelforum.com/member.php...o&userid=36350
View this thread: http://www.excelforum.com/showthread...hreadid=561356



All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com