#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default vba dynamic

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.SortF ields.Clear
ActiveWorkbook.Worksheets(€œSheet2€³).Sort.SortF ields.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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default vba dynamic

Hi

Try this:

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

Regards,
Per

On 12 Feb., 01:32, danial mansoor wrote:
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.SortF ields.Clear
ActiveWorkbook.Worksheets(€œSheet2€³).Sort.SortF ields.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!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic pivot table linked to dynamic excel spreadsheets FErd Excel Worksheet Functions 0 April 29th 10 10:44 PM
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Charts and Charting in Excel 0 March 1st 06 01:05 AM
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Excel Programming 0 March 1st 06 01:05 AM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
select dynamic range with dynamic start point Juli Excel Programming 1 August 31st 05 12:05 AM


All times are GMT +1. The time now is 05:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"