Sorting by columns no headers

teodormircea

Active Member
Joined
Jan 8, 2008
Messages
331
Hello EVERY ONE

I made this code that in the first time , identify a used range minus last row(there i have subtotals)
i Have 3 combobox to select columns.
I need a code to sort Ascending the selected range by selected columns

here what i've done till now.
Code:
Sub FindUsedRange_SORT()
     
    Dim Rng1            As Range
   
    CBO_Fill
    Set Rng1 = RealUsedRange
   If Rng1 Is Nothing Then
      MsgBox "There is no used range, the worksheet is empty."
  Else
       Rng1.Select
       
     End If
End Sub

 
Public Function RealUsedRange() As Range
     
    Dim FirstRow        As Long
    Dim LastRow         As Long
    Dim FirstColumn     As Integer
    Dim LastColumn      As Integer
     
    On Error Resume Next
     
    FirstRow = Cells.Find(What:="*", After:=Range("IV65536"), LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
    
    FirstColumn = Cells.Find(What:="*", After:=Range("IV65536"), LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column
     
    LastRow = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row - 1
     
    LastColumn = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
     
    Set RealUsedRange = Range(Cells(FirstRow, FirstColumn), Cells(LastRow, LastColumn))
     
    On Error GoTo 0
     
End Function
Private Sub CBO_Fill()
    Dim oRng As Range
     'Remplit la Combo
    With ActiveSheet
        Set oRng = Range(.Cells(1, 1), .Cells(1, Columns.Count).End(xlToLeft))
        ComboBox1.List = Application.Transpose(oRng)
        ComboBox2.List = Application.Transpose(oRng)
        ComboBox3.List = Application.Transpose(oRng)
    End With
    ComboBox1.ListIndex = 0
    ComboBox2.ListIndex = 0
    ComboBox3.ListIndex = 0
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,206,833
Messages
6,075,126
Members
446,123
Latest member
junkyardforme

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top