vba dynamic

D

danial mansoor

hi experts!
i ve this macro but i want to make it dynamic how can i do it?

Sub Macro1()
‘
‘ Macro1 Macro
‘
‘finalrow = Cells(Rows.Count, 1).End(xlUp).Value
ActiveWorkbook.Worksheets(“Sheet2″).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(“Sheet2″).Sort.SortFields.Add
Key:=ActiveCell, _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(“Sheet2″).Sort
..SetRange ActiveCell.Range(“A1:A14″)
..Header = xlNo
..MatchCase = False
..Orientation = xlTopToBottom
..SortMethod = xlPinYin
..Apply
End With
End Sub


i used this code .SetRange ActiveCell.Range(Selection,
Selection.End(xlDown)) instead of .SetRange ActiveCell.Range(“A1:A14″)
but was not able to make my macro dynamic how can i make my macro
dynamic?
make macro dynamic help!
 
P

Per Jessen

Hi

Try this:

SetRange Range(selection,Range(selection).end(xldown))

Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Undo Macro Action 3
Modify Sort Routine to inlcude All Data 2
VBA 2 Codes 2
Clear Check Box 2
Sort Dynamic Range 4
Sorting Question 5
Stay on Active Sheet 2
Sort Macro Compatibility 3

Top