Sorting mltple sections of data based on 1 cell in ea sect.

awwphooey

New Member
Joined
Aug 15, 2007
Messages
15
Hello-

Like a bad penny… :rolleyes:

I am now trying to sort multiple sections of data into numerical order, based on one cell within each section. For example, I have this:
business objects spaced out test.xls
ABCDEFGH
419CRF63637FN944(Review)rg6/29/0610:35AM7/26/064:57PM27:6:22
420CRF63637FN944(Approve)rg8/1/063:12PM9/15/064:41PM14:1:28
421CRF63637FN944(Approve)lmilano8/1/063:12PM8/2/061:23PM0:22:11
422CRF63637FN944(Approve)angela8/1/063:12PM8/2/0611:22AM0:20:09
423CRF63637FN944(Approve)lhg8/1/063:12PM8/1/064:23PM0:1:10
42474days3:2374.14
425CRF636251770.039(Approve)bsanford7/27/0612:00PM8/23/065:16PM27:5:15
426CRF636251770.039(Review)cseidt6/29/0610:33AM7/20/064:32PM21:5:59
427CRF636251770.039(Approve)hoey7/27/0612:00PM9/12/063:32PM16:3:31
42895days14:4795.62
Report 1


Right now, I have it configured to place the formatted totals in column G in the empty row just below each block. I also have it putting the raw totals in column K in case I need to do any further math with the numbers, as the formatted totals are text that can't be manipulated mathematically. I'd like to sort as follows:
business objects spaced out test.xls
ABCDEFGH
419CRF636251770.039(Approve)bsanford7/27/0612:00PM8/23/065:16PM27:5:15
420CRF636251770.039(Review)cseidt6/29/0610:33AM7/20/064:32PM21:5:59
421CRF636251770.039(Approve)hoey7/27/0612:00PM9/12/063:32PM16:3:31
42295days14:4795.62
423CRF63637FN944(Review)rg6/29/0610:35AM7/26/064:57PM27:6:22
424CRF63637FN944(Approve)rg8/1/063:12PM9/15/064:41PM14:1:28
425CRF63637FN944(Approve)lmilano8/1/063:12PM8/2/061:23PM0:22:11
426CRF63637FN944(Approve)angela8/1/063:12PM8/2/0611:22AM0:20:09
427CRF63637FN944(Approve)lhg8/1/063:12PM8/1/064:23PM0:1:10
42874days3:2374.14
Report 1


There are multiple sections, just showing 2 for brevity.
Thanks in advance for any help available!
Phoo
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Are your totals in columns G and H, or in columns G and K ?

Other than the two totals, is there anything else in the "total" rows in other columns?
 
Upvote 0
Hi Boller-

My totals are in columns G and H, there are no other colums.

If it helps, this is the script one of the tech guys here at work gave me, which allowed me to total up the days, hours and minutes spent on each CRF (again, the CRF number is just a document number. I'm tryng to ascertain the time spent on processing each document):

Sub CalculateSubtotals()

Dim oSheet As Worksheet
Dim iRowIndex As Long
Dim sCurrentRowLabel As String
Dim sNewRowLabel As String
Dim runningTotal As Double
Dim iConsecutiveEmptyRows As Integer
Dim numDays As Integer
Dim fractionalDays As Double
Dim numHours As Integer
Dim countTotals As Long

Set oSheet = ActiveWorkbook.ActiveSheet
iRowIndex = 3
iConsecutiveEmptyRows = 0
sCurrentRowLabel = oSheet.Rows(iRowIndex).Cells(1, 1)
runningTotal = (oSheet.Rows(iRowIndex).Cells(1, 6) - oSheet.Rows(iRowIndex).Cells(1, 5))
countTotals = 0

Do While (iConsecutiveEmptyRows < 5)
iRowIndex = iRowIndex + 1
sNewRowLabel = oSheet.Rows(iRowIndex).Cells(1, 1)
If (sNewRowLabel = sCurrentRowLabel) And (sNewRowLabel <> "") Then
runningTotal = runningTotal + (oSheet.Rows(iRowIndex).Cells(1, 6) - oSheet.Rows(iRowIndex).Cells(1, 5))
Else
If (sNewRowLabel = "") And (sCurrentRowLabel <> "") Then
numDays = Int(runningTotal) - (runningTotal Mod 1)
fractionalDays = runningTotal - numDays
numMinutes = fractionalDays * 1440
numHours = (numMinutes \ 60)
numMinutes = (numMinutes - (numHours * 60)) \ 1
oSheet.Rows(iRowIndex).Cells(1, 11) = runningTotal
oSheet.Rows(iRowIndex).Cells(1, 7) = CStr(numDays) + " days " + CStr(numHours) + ":" + CStr(numMinutes)
runningTotal = 0#
countTotals = countTotals + 1
ElseIf (sNewRowLabel = "") And (sCurrentRowLabel = "") Then
' no op
Else
runningTotal = (oSheet.Rows(iRowIndex).Cells(1, 6) - oSheet.Rows(iRowIndex).Cells(1, 5))
End If

sCurrentRowLabel = sNewRowLabel
If (sNewRowLabel = "") Then
iConsecutiveEmptyRows = iConsecutiveEmptyRows + 1
Else
iConsecutiveEmptyRows = 0
End If
End If
Loop

MsgBox "Done!" + vbCrLf + vbCrLf + "Processed " + CStr(countTotals) + " totals."
End Sub

Now, I'm trying to sort each section (each CRF set), by the greatest amount of time down to the least.

Phoo
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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