# Numbers from first column

G

#### gwc

Col A contains:
1
5
7
10
14

Col B contains:
2
3
6

Col C contains:
4
6
8
11
13

Col D contains:
1
5
8
9
10
12
13
14
15

How do I put, in Col E, each number from the FIRST column it occurred
in:
1 (came from Col A)
2 (came from Col B)
3 (came from Col B)
4 (came from Col C)
5 (came from Col A)
6 (came from Col B)
7 (came from Col A)
8 (came from Col C)
9 (came from Col D)
10 (came from Col A)
11 (came from Col C)
12 (came from Col D)
13 (came from Col C)
14 (came from Col A)
15 (came from Col D)

D

#### Don Guillett

Col A contains:
1
5
7
10
14

Col B contains:
2
3
6

Col C contains:
4
6
8
11
13

Col D contains:
1
5
8
9
10
12
13
14
15

How do I put, in Col E, each number from the FIRST column it occurred
in:
1 (came from Col A)
2 (came from Col B)
3 (came from Col B)
4 (came from Col C)
5 (came from Col A)
6 (came from Col B)
7 (came from Col A)
8 (came from Col C)
9 (came from Col D)
10 (came from Col A)
11 (came from Col C)
12 (came from Col D)
13 (came from Col C)
14 (came from Col A)
15 (came from Col D)

try this macro

Option Explicit
Sub camefromcolSAS()
Dim i As Long
With ActiveSheet.UsedRange
5 On Error Resume Next
For i = 1 To Application.Max(.Value)
Cells(i, "e") = i & " found in col " & .Find(What:=i, _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext).Column
Next i
End With
Columns("e").AutoFit
End Sub

D

#### Don Guillett

Col A contains:
1
5
7
10
14

Col B contains:
2
3
6

Col C contains:
4
6
8
11
13

Col D contains:
1
5
8
9
10
12
13
14
15

How do I put, in Col E, each number from the FIRST column it occurred
in:
1 (came from Col A)
2 (came from Col B)
3 (came from Col B)
4 (came from Col C)
5 (came from Col A)
6 (came from Col B)
7 (came from Col A)
8 (came from Col C)
9 (came from Col D)
10 (came from Col A)
11 (came from Col C)
12 (came from Col D)
13 (came from Col C)
14 (came from Col A)
15 (came from Col D)

oops. Need to search by COLUMNS
Option Explicit
Sub camefromcolSAS()
Dim i As Long
With ActiveSheet.UsedRange
5 On Error Resume Next
For i = 1 To Application.Max(.Value)
Cells(i, "e") = i & " found in col " & .Find(What:=i, _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext).Column
Next i
End With
Columns("e").AutoFit
End Sub

G

#### gwc

Thanks, Don. You macro worked. But I just realized that the cells in
columns A thru D actually contain more data than just the number. For
example;

Col A contains:
1 xxxxxxx
5 yyyyyyyyyyyyyy
7 xxxxxxx
10 yyyyyyyyyyyyyy
14 zzz

Col B contains:
2 yyyyyyyyyyyyyy
3 xxxxxxx
6 zzz

Col C contains:
4 xxxxxxx
6 yyyyyyyyyyyyyy
8 xxxxxxx
11 zzz
13 xxxxxxx

Col D contains:
1 yyyyyyyyyyyyyy
5 yyyyyyyyyyyyyy
8 xxxxxxx
9 zzz
10 xxxxxxx
12 xxxxxxx
13 xxxxxxx
14 yyyyyyyyyyyyyy
15 xxxxxxx

How do I put the number plus its other data from the FIRST column it
occurred in into Col E? For example:
1 xxxxxxx (came from Col A)
2 yyyyyyyyyyyyyy (came from Col B)
3 xxxxxxx (came from Col B)
4 xxxxxxx (came from Col C)
5 yyyyyyyyyyyyyy (came from Col A)
6 yyyyyyyyyyyyyy (came from Col B)
7 xxxxxxx (came from Col A)
8 xxxxxxx (came from Col C)
9 zzz (came from Col D)
10 yyyyyyyyyyyyyy (came from Col A)
11 zzz (came from Col C)
12 xxxxxxx (came from Col D)
13 xxxxxxx (came from Col C)
14 zzz (came from Col A)
15 xxxxxxx (came from Col D)

G

#### gwc

Thanks, Don. Your macro worked. But I just realized that the cells in
columns A thru D actually contain more data than just the number. For
example:

Col A contains:
1 xxxxxxx
5 yyyyyyyyyyyyyy
7 xxxxxxx
10 yyyyyyyyyyyyyy
14 zzz

Col B contains:
2 yyyyyyyyyyyyyy
3 xxxxxxx
6 zzz

Col C contains:
4 xxxxxxx
6 yyyyyyyyyyyyyy
8 xxxxxxx
11 zzz
13 xxxxxxx

Col D contains:
1 yyyyyyyyyyyyyy
5 yyyyyyyyyyyyyy
8 xxxxxxx
9 zzz
10 xxxxxxx
12 xxxxxxx
13 xxxxxxx
14 yyyyyyyyyyyyyy
15 xxxxxxx

How do I put the number plus its other data from the FIRST column it
occurred in into Col E? For example:

1 xxxxxxx (came from Col A)
2 yyyyyyyyyyyyyy (came from Col B)
3 xxxxxxx (came from Col B)
4 xxxxxxx (came from Col C)
5 yyyyyyyyyyyyyy (came from Col A)
6 yyyyyyyyyyyyyy (came from Col B)
7 xxxxxxx (came from Col A)
8 xxxxxxx (came from Col C)
9 zzz (came from Col D)
10 yyyyyyyyyyyyyy (came from Col A)
11 zzz (came from Col C)
12 xxxxxxx (came from Col D)
13 xxxxxxx (came from Col C)
14 zzz (came from Col A)
15 xxxxxxx (came from Col D)

(Note: I do NOT need the "(came from Col xxx)" info).

D

#### Don Guillett

Col A contains:
1
5
7
10
14

Col B contains:
2
3
6

Col C contains:
4
6
8
11
13

Col D contains:
1
5
8
9
10
12
13
14
15

How do I put, in Col E, each number from the FIRST column it occurred
in:
1 (came from Col A)
2 (came from Col B)
3 (came from Col B)
4 (came from Col C)
5 (came from Col A)
6 (came from Col B)
7 (came from Col A)
8 (came from Col C)
9 (came from Col D)
10 (came from Col A)
11 (came from Col C)
12 (came from Col D)
13 (came from Col C)
14 (came from Col A)
15 (came from Col D)
I no longer have the test file so send your file to dguillett1 @gmail.com