![]() |
|
|
|||||||
| FlashChat | Actuarial Discussion | Preliminary Exams | CAS/SOA Exams | Cyberchat | Around the World | Suggestions |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I have an export from a database in Excel. Each record has a unique identifier. I would like to make sure the records are in a sorted order and each identifier is 1+identifier of the previous record.
Or, an example: Code:
5 Apple 6 Orange 7 Banana 8 Monkey Anyone? |
|
#3
|
||||
|
||||
|
Quote:
'Unique record identifier is a (long) integer 'in Column 1 Dim J As Long Dim Result As Boolean Result = True 'set as Default For J = 2 To R.Rows.Count If R(J, 1) <> R(J - 1, 1) + 1 Then Result = False Exit For End If Next J IsOrdered = Result End Function Am I missing something? Brad
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: |
|
#4
|
|||
|
|||
|
I forgot to mention a strong preference for a non-VBA solution. (What they don't understand....)
Quote:
- last number = first number + number of records - 1 - MAXA(OFFSET(A7,,,B3,1)-OFFSET(A6,,,B3,1) equals 1 Where the data starts at A6 and B3 contains the number of records |
|
#5
|
||||
|
||||
|
Quote:
Brad
__________________
Brad Gile, FSA, MAAA Affiliate Member of the CAS Dedicated Retired Actuary Spoiler: Spoiler: |
|
#6
|
|||
|
|||
|
Zorro, how about the following?
Assuming your record identifiers are in cells C4:C8, then {=SUM((((C5:C8)-(C4:C7))=1)*1)} (Don't forget to enter as an array formula) This counts the number of differences between sequential records that equal 1. If all your identifiers are sequential, then the result will be one less than the number of records, so you could modify it to the following {=SUM((((C5:C8)-(C4:C7))=1)*1)-COUNT(C4:C8)+1} In this case, anything other than a zero is problem. Is this what you are looking for? Hedges |
|
#7
|
||||
|
||||
|
Quote:
|
|
#8
|
||||
|
||||
|
Assuming cells A2 through A7 contain the numbers 1 through 6
Then Cell A1 = {=AND((A2:A6 + 1) = A3:A7)} Enter this as an array function by using Shift-Ctrl-Enter Bon Appetit!
__________________
Emoticon Contest winner ![]() ACOOP III Main Event Winner and Overall Money Champion |
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
|||
|
|||
|
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|