Previous Current Answer
1058 1063 1058
1059 1065 1059
1060 1066 1060
1061 1067 1061
1063 1069 1063
1065 1071 1065
1066 1072 1066
1067 1073 1067
1069 1074 1069
1071 1075 1071
1072 1076 1072
1073 1077 1073
1074 1078 1074
1075 1080 1075
1076 1081 1076
1077 1082 1077
1078 1084 1078
1080 1085 1080
1081 1086 1081
1082 1087 1082
1084 1088 1084
1089 1085
1090 1086
1093 1087
1088
1089
1090
1093
To put it into place, open the workbook and press [Alt]+[F11] to open the VB
Editor and then choose Insert --> Module. Copy the code below and paste it
into the code module shown. Change the definitions of the Const values to
match the layout of your worksheet and then close the VB Editor. Run it from
Tools --> Macros --> Macro or from the [Developer] ribbon in Excel 2007.
Sub CreateAnswerList()
'change these as required
Const prevCol = "A"
Const currCol = "B"
Const answCol = "C"
Const firstDataRow = 2
'variables used
Dim sourceList As Range
Dim anySourceEntry As Range
Dim destList As Range
Dim anyDestEntry As Range
Dim lastRow As Long
Dim foundFlag As Boolean
Application.ScreenUpdating = False ' for performance
'begin by moving the Previous List
lastRow = Range(prevCol & Rows.Count).End(xlUp).Row
If lastRow < firstDataRow Then
lastRow = firstDataRow
End If
Set sourceList = Range(prevCol & firstDataRow & _
":" & prevCol & lastRow)
lastRow = Range(answCol & Rows.Count).End(xlUp).Row
Set destList = Range(answCol & firstDataRow & _
":" & answCol & lastRow)
For Each anySourceEntry In sourceList
foundFlag = False
For Each anyDestEntry In destList
If anySourceEntry = anyDestEntry Then
foundFlag = True
Exit For
End If
Next
If Not foundFlag Then
'a new entry, add to Answer list
lastRow = lastRow + 1
Range(answCol & lastRow) = anySourceEntry
'redefine destList
Set destList = Range(answCol & firstDataRow & _
":" & answCol & lastRow)
End If
Next
'add the Current list contents
lastRow = Range(currCol & Rows.Count).End(xlUp).Row
If lastRow < firstDataRow Then
lastRow = firstDataRow
End If
Set sourceList = Range(currCol & firstDataRow & _
":" & currCol & lastRow)
lastRow = Range(answCol & Rows.Count).End(xlUp).Row
Set destList = Range(answCol & firstDataRow & _
":" & answCol & lastRow)
For Each anySourceEntry In sourceList
foundFlag = False
For Each anyDestEntry In destList
If anySourceEntry = anyDestEntry Then
foundFlag = True
Exit For
End If
Next
If Not foundFlag Then
'a new entry, add to Answer list
lastRow = lastRow + 1
Range(answCol & lastRow) = anySourceEntry
'redefine destList
Set destList = Range(answCol & firstDataRow & _
":" & answCol & lastRow)
End If
Next
'housekeeping
Set sourceList = Nothing
Set destList = Nothing
End Sub
Sub AutoFilterSheet()
Dim lngARow As Long, lngBRow As Long
lngARow = Cells(Rows.Count, "A").End(xlUp).Row
Range("C1") = "Answer"
Range("A2:A" & lngARow).Copy Range("C2")
lngBRow = Cells(Rows.Count, "B").End(xlUp).Row
Range("B2:B" & lngBRow).Copy Range("C" & lngARow + 1)
Columns("C:C").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("D1"), Unique:=True
Columns(3).Delete
End Sub
If this post helps click Yes
---------------
Jacob Skaria
Previous Current Answer
1058 1063 1058
1059 1065 1059
1060 1066 1060
1061 1067 1061
1063 1069 1063
1065 1071 1065
1066 1072 1066
1067 1073 1067
1069 1074 1069
1071 1075 1071
1072 1076 1072
1073 1077 1073
1074 1078 1074
1075 1080 1075
1076 1081 1076
1077 1082 1077
1078 1084 1078
1080 1085 1080
1081 1086 1081
1082 1087 1082
1084 1088 1084
1089
1090 1086
1093 1087
1088
1089
1090
1093
1094
1095
1096
1097
1098
1099
1085
If this post helps click Yes
---------------
Jacob Skaria
A Col B Col C Col
I assume that you are having the previous values in Column A and Current
Values in Column B, and in C2 onwards you require the values of Col A & Col B
in Ascending Order without any duplications.
Just paste the below formula’s in that particular cells to derive the result.
In Cell C2
=SMALL(A:B,1)
In Cell D2
=COUNTIF(A:B,C2)
In Cell C3
=SMALL(A:B,SUM($D$2:D2)+1)
In Cell D3
=COUNTIF(A:B,C3)
Now Place the cursor in C3 cell and hold shift key and extend your selection
to D3 (i.e.C3 to D3) hold the shift key and Down Arrow and extend the
selection upto C2 to D40 and press Cntrl+D.
The Result #NUM! in C Column and the value “0” in D Column is the end of the
Result.
Hope this may be helpful to you…
If this post helps, Click Yes!
--------------------
(Ms-Exl-Learner)
--------------------