Dynamic named Range en sorteren

HV_L

New Member
Joined
Dec 4, 2009
Messages
43
Hoi,
Ik heb deze VBA code gevonden en gebruikt om een dynamische named range te maken (NAW):
Code:
Public Sub CreateDynamicRange()

    With Selection.CurrentRegion.Cells(1)
        .Parent.Parent.Names.Add InputBox("Naam"), Replace("=OFFSET(§" & .Address & ",,,COUNTA(§" & _
        .EntireColumn.Address & ")," & "COUNTA(§" & .EntireRow.Address & "))", "§", "'" & .Parent.Name & "'!")
    End With

End Sub
Nou wil ik per kolomheader kunnen selecteren middels een knop bovenaan de kolom.
Het lijkt erop dat deze range stopt als ie een lege cel tegenkomt.

Twee vragen:
1.Klopt de VBA code en neemt ie gewoon lege cellen mee in de range?
2.Welke code heb ik nodig om via een knop de range op kolom te sorteren?

Gebruik nu deze code, maar die neemt dus niet de hele range mee
Code:
Sub SortRawData()
'
' SortRawData Macro
' Sort Raw Data to Hasten Lookups
'
  Worksheets("NAW").Select
  With ActiveSheet.Sort
    .SortFields.Clear
    .SortFields.Add Key:=Range("A2:A"), _
      SortOn:=xlSortOnValues, Order:=xlAscending, _
      DataOption:=xlSortNormal
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
  End With
Wie helpt me hierdoor?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,226,695
Messages
6,192,475
Members
453,726
Latest member
JoeH57

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