Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Dynamic sort

I have a set of 10 named cells that contain calculated dates. The name of each single cell ranges describes the date value. I would like to write a UDF that can be used to dynamically sort the dates and return them to the worksheet in sorted order.. I would end up with a list of 10 dates parried with their corresponding name. Changes in the model would recalculated the order of the list

I could not find a simple way to read the keyed pairs into an array or some other structure sort it and return to the worksheet (I am assuming as an array function).

Does anyone have an example of this? Or some ideas? Any help or hints would be appreciated.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Dynamic sort

hi,

Sub ListDate()
Dim Dico As Object, c As Range
Set Dico = CreateObject("Scripting.Dictionary")
For Each nms In Names
Dico.Add Range(nms.Value), nms.Name
Next
With Sheets("Feuil2") '--- adapt the sheet name
..[A2].Resize(Dico.Count) = Application.Transpose(Dico.keys)
..[B2].Resize(Dico.Count) = Application.Transpose(Dico.Items)
..[A2].Sort Key1:=.[A2], Order1:=xlAscending, Header:=xlNo
End With
End Sub

isabelle
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Dynamic sort

On Thursday, April 9, 2015 at 10:23:14 PM UTC-4, isabelle wrote:
hi,

Sub ListDate()
Dim Dico As Object, c As Range
Set Dico = CreateObject("Scripting.Dictionary")
For Each nms In Names
Dico.Add Range(nms.Value), nms.Name
Next
With Sheets("Feuil2") '--- adapt the sheet name
.[A2].Resize(Dico.Count) = Application.Transpose(Dico.keys)
.[B2].Resize(Dico.Count) = Application.Transpose(Dico.Items)
.[A2].Sort Key1:=.[A2], Order1:=xlAscending, Header:=xlNo
End With
End Sub

isabelle


this provides some clues but it looks like the data is being manually sorted on the sheet using excel functions and triggered when the sub is run.

I think what I am trying to do is t to do all the sorting in a vba UDF function that entered into excel as an array function {} and have it continually sorting as other calcs in the workbook change.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Dynamic sort


on a new sheet,
select the range A1:A10
paste this formula in range A1

=SMALL((name1;name2;name3;name4;name5;name6;name7; name8;name9;name10);ROW())
it is an array formula to insert with CTRL+Shift+Enter

isabelle
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Dynamic sort

On Friday, April 10, 2015 at 1:15:45 PM UTC-4, isabelle wrote:
on a new sheet,
select the range A1:A10
paste this formula in range A1

=SMALL((name1;name2;name3;name4;name5;name6;name7; name8;name9;name10);ROW())
it is an array formula to insert with CTRL+Shift+Enter

isabelle


Thanks. That sorts the date data without any UDF but I now need the name of each of those named ranges returned in the next column based on the sort. If the dates were unique I could easily do a lookup but there may be duplicate dates.

That is why I was leaning towards the UDF that could somehow sort the date-name pairs and return a sorted array.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Dynamic sort

Function TheName(rng As Range) As String
For Each nms In Names
If rng = Range(nms.Value) Then TheName = nms.Name: Exit Function
Next
End Function

=TheName(A1)

isabelle

Le 2015-04-10 13:31, mg a écrit :

Thanks. That sorts the date data without any UDF

but I now need the name of each of those named ranges returned in the next
column based on the sort.
If the dates were unique I could easily do a lookup but there may be duplicate
dates.

That is why I was leaning towards the UDF that could somehow sort the date-name pairs and return a sorted array.

  #7   Report Post  
Banned
 
Posts: 11
Default

Chat box - Create and design free live chat box php embed iframe html source code for your website forum blog wap without advertisement.
  #8   Report Post  
Banned
 
Posts: 11
Default

sim sinh vien gia re
[size=3][color=#141823]SIM SINH VIÊN GIÁ RẺ
SIM ĐOÀN VIÊN GIÁ RẺ
SIM SINH VIÊN VIETTEL GIÁ RẺ
SIM SINH VIÊN MOBIFONE GIÁ RẺ
SIM SINH VIÊN VINAPHONE GIÁ RẺ
...Xem thêm


[center]https://scontent-dfw.xx.fbcdn.net/hp...e1&oe=55A23F97[url=https://www.facebook.com/simsinhviengiare.vn][b]Sim Sinh Viên Mobi Giá Rẻ
  #9   Report Post  
Banned
 
Posts: 11
Default

tin nước nga Tất cả thông tin, h́nh ảnh, video clip về Nga tổng hợp từ tất cả các báo điện tử tại ... Cực để tạo điều kiện thuận lợi cho các công ty của nước này khai thác
tin tức nước Nga
Xem thêm: http://vietbao.ru/italia-hoa-may-man...post42745.html
  #10   Report Post  
Banned
 
Posts: 11
Default

Sim Sinh Viên Giá Rẻ
[size=3][color=#141823]SIM SINH VIÊN GIÁ RẺ
SIM ĐOÀN VIÊN GIÁ RẺ
SIM SINH VIÊN VIETTEL GIÁ RẺ
SIM SINH VIÊN MOBIFONE GIÁ RẺ
SIM SINH VIÊN VINAPHONE GIÁ RẺ
...Xem thêm




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
Macro to sort, format, sum, a dynamic set of data Flipper Excel Programming 2 May 20th 10 05:54 AM
dynamic sort jeffatwork Excel Programming 4 April 13th 10 10:19 PM
Sort Dynamic Range lightjag Excel Programming 4 March 21st 09 09:00 PM
Dynamic Sort Macro Chris Excel Programming 1 September 27th 03 11:43 PM
Dynamic Sort bw Excel Programming 0 July 28th 03 07:57 PM


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

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

About Us

"It's about Microsoft Excel"