Numbers from first column
On Sunday, April 1, 2012 1:13:00 PM UTC-5, gwc wrote:
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
|