LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Sort a Record Structure within a Report Routine

Tom,

Thanks...I tried this last week and it worked very well and solved my
problem...thanks for your help

Scott

"scott56hannah" wrote:

Tom,

Thanks for that I will give it a go within my routine and see if I can get
it working...

Scott

"Tom Ogilvy" wrote:

Here is an example:

Type ProjectData
a As Long
b As Long
c As String
End Type

Type ResourceProjectData
strResourceName As String
strPrimaryRole As String
intResourceTotalHours(1 To 12) As Integer
ProjectDetails(1 To 500) As ProjectData
End Type

Sub ABC()
Dim n As Long
Dim r() As ResourceProjectData
Dim rTemp As ResourceProjectData
Dim i As Long, j As Long
n = 10
ReDim r(1 To n)
' populate the array
For i = 1 To n
PopData r(i)
Next

For i = 1 To n - 1
For j = i + 1 To n
If r(i).strPrimaryRole r(j).strPrimaryRole Then
rTemp = r(i)
r(i) = r(j)
r(j) = rTemp
End If
Next j
Next i
For i = 1 To n
Debug.Print r(i).strPrimaryRole
Next
End Sub

Sub PopData(rr As ResourceProjectData)
rr.strResourceName = Chr(Int(Rnd() * 26 + 65)) _
& Chr(Int(Rnd() * 26 + 65))
rr.strPrimaryRole = Chr(Int(Rnd() * 26 + 65))
For i = 1 To 12
rr.intResourceTotalHours(i) = Int(Rnd() * 100 + 1)
Next
For i = 1 To 500
rr.ProjectDetails(i).a = Int(Rnd() * 26 + 65)
rr.ProjectDetails(i).b = Int(Rnd() * 26 + 65)
rr.ProjectDetails(i).c = Chr(Int(Rnd() * 26 + 65))
Next
End Sub

--
Regards,
Tom Ogilvy


"scott56hannah" wrote:

Hi,
I want to be able to read some data into a record structure and then
depending on a users selection I want to be able to sort that structure
different ways..see the structure below....

Type ResourceProjectData
strResourceName As String
strPrimaryRole As String
intResourceTotalHours(1 To 12) As Integer
ProjectDetails(1 To 500) As ProjectData
End Type

So for instance the the data is read in sorted by ResourceName....I want to
be able to sort the record by PrimaryRole instead and then ResourceName....is
there anyway to do this programmatically or do I have to read out data to a
temporary sheet and the sort with worksheet functions ?

Thanks for any help

 
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
Sort Routine Platinum girl[_2_] Excel Discussion (Misc queries) 0 March 9th 07 03:21 PM
De-concatenate but maintain relationship/record structure CompleteNewb Excel Programming 0 January 19th 07 03:48 AM
Generalising sort routine lexcel Excel Programming 0 June 3rd 06 02:57 PM
how can I use excel to automatically generate routine report? scott Excel Worksheet Functions 0 December 29th 05 09:02 PM
Sort Routine VBA weeper Excel Programming 2 September 29th 04 02:59 PM


All times are GMT +1. The time now is 12:25 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"