Hello.
I am trying to modify the unique and sort code below (as provided by someone on the forum) to allow it to stand alone ie. not have to go into the editor to change the ranges.
To this end I was hoping to use the inbox method to return the ranges. Everything I have read tells me to define the inputbox as type 8. Which is what I thought I had done.
However. It still returns the cell value rather than the range.
What am I doing wrong?
Thanks
G12
Sub UniqueSort3()
Dim a, e As Variant
Dim Rng1 As Range
Dim Rng2 As Range
Set Rng1 = Application.InputBox( _
prompt:="Specify a Cell to Start From:", _
Title:="Input Cell Reference", Type:=8)
If Rng1 Is Nothing Then Exit Sub
Set Rng2 = Application.InputBox( _
prompt:="Specify a Destination Cell:", _
Type:=8)
If Rng2 Is Nothing Then Exit Sub
'' Rspn = InputBox("Please Insert Sorting Start Point Cell", "Input Cell Reference", "For Example C3")
''
'' If Rspn = "" Then GoTo SRTCNL
''
''' Range("E2:K2").Value = Rspn
a = Range(Rng1, Range(Rng1(remember to adjust range for column value only) & Rows.Count).End(xlUp)).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each e In a
.Item(e) = .Item(e) + 1
Next
Range(Rng2).Resize(.Count, 2).Value = Application.Transpose(Array(.keys, .items))
End With
Range(Rng2).CurrentRegion.Sort Range(Rng2), 1
SRTCNL:
MsgBox "The Unique and Sort Has Been Cancelled", vbOKOnly
End Sub
I am trying to modify the unique and sort code below (as provided by someone on the forum) to allow it to stand alone ie. not have to go into the editor to change the ranges.
To this end I was hoping to use the inbox method to return the ranges. Everything I have read tells me to define the inputbox as type 8. Which is what I thought I had done.
However. It still returns the cell value rather than the range.
What am I doing wrong?
Thanks
G12
Sub UniqueSort3()
Dim a, e As Variant
Dim Rng1 As Range
Dim Rng2 As Range
Set Rng1 = Application.InputBox( _
prompt:="Specify a Cell to Start From:", _
Title:="Input Cell Reference", Type:=8)
If Rng1 Is Nothing Then Exit Sub
Set Rng2 = Application.InputBox( _
prompt:="Specify a Destination Cell:", _
Type:=8)
If Rng2 Is Nothing Then Exit Sub
'' Rspn = InputBox("Please Insert Sorting Start Point Cell", "Input Cell Reference", "For Example C3")
''
'' If Rspn = "" Then GoTo SRTCNL
''
''' Range("E2:K2").Value = Rspn
a = Range(Rng1, Range(Rng1(remember to adjust range for column value only) & Rows.Count).End(xlUp)).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each e In a
.Item(e) = .Item(e) + 1
Next
Range(Rng2).Resize(.Count, 2).Value = Application.Transpose(Array(.keys, .items))
End With
Range(Rng2).CurrentRegion.Sort Range(Rng2), 1
SRTCNL:
MsgBox "The Unique and Sort Has Been Cancelled", vbOKOnly
End Sub