Re: Sorting Data based on Dep Time and Reg Code using VB code
So , it means , there is no duplicate Flight number and no same Dep Airport and Arr Airport , correct?
Re: Sorting Data based on Dep Time and Reg Code using VB code
So , it means , there is no duplicate Flight number and no same Dep Airport and Arr Airport , correct?
Re: Sorting Data based on Dep Time and Reg Code using VB code
Is it "run-time error '9'?
Isn't it "1004"?
If 1004, most probably a blank cell in col.A, otherwise I need to see the data.
I have no problem with your sample data.
Re: Sorting Data based on Dep Time and Reg Code using VB code
It is "run-time error '9'
Thanks.
Re: Sorting Data based on Dep Time and Reg Code using VB code
I need to see the file, anyway.
Re: Sorting Data based on Dep Time and Reg Code using VB code
When I used the code on the real data, I got this error and I guess I know why, and that is because of the blank data at the end of the last record including the $ signs and the NIL sign in the blank row right after the real records.
[TABLE="width: 589"]
MMM4537
735
945
$OVI
480
LIMC
LEMD
23B
NIL
NIL
$
NIL
$
$
$
$
$
[/TABLE]
Believe it or not, although the column A is blank at the end of the record but it seems that somehow the cursor stops at some blank columns.
When I removed all the blank columns and rows after the last record, your code worked perfect.
If the code can remove any blank columns and rows including the blank $ sign and the last NIL all the way down to let's say row 900, I believe it will work.
The blanks including the blank $ signs extend down some times to row 900.
Thank you.
Re: Sorting Data based on Dep Time and Reg Code using VB code
This is working , Thank you very much Jindon , I will monitor it for couple of days and revert with the findings.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Hello Jindon, Sorry for late reply , I was on the go, but Thank you very much, it is working perfect, I really appreciate your kind help and patience.
Re: Sorting Data based on Dep Time and Reg Code using VB code
You are welcome and thanks for the feedback.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Hello Jindon,
Agian facing sorting problem when the A2 is blank :
I was trying to sort the data by Flight# , but the result is that the Blanks that include $ comes on the top , then the data at the bottom , How can I do the sorting where by the blanks including the $ signs in the blank columns are ignored?
Thanks.
DataBase
[TABLE="width: 0"]
Flight#
Dep Time
Arr Time
Reg Code
Pax Count
Dep Airport
Arr Airport
Class
Trip No.1
Trip No.2
MMM8570
900
955
$SSSL
EGLL
EDDF
XX80
43000333
43000333
MMM8570
1600
1655
$SSSL
EDDF
EGLL
XX80
43000333
49000333
MMM6074
40
420
$OVD
480
LIRF
EGLL
23B
NIL
NIL
MMM7444
45
435
$OVI
446
LEMD
LIMC
23B
NIL
NIL
MMM3773
100
350
$XMX
EDDF
EGLL
22A
NIL
NIL
MMM733
120
735
$OXH
285
EDDK
EDDF
B70
NIL
NIL
MMM4860
511
540
$AVV
LIRR
LIRR
123
NIL
NIL
MMM734
600
945
$MMT
433
LIMC
LIMJ
22A
NIL
NIL
MMM450
615
800
$MMT
424
LIMJ
LIMC
22A
NIL
NIL
MMM3844
650
745
$OXX
EDDF
EGLL
B70
NIL
NIL
MMM4766
720
840
$OVD
480
EGLL
LIRF
23B
NIL
NIL
MMM4860
730
855
$AVV
465
LIRR
LIRF
123
NIL
NIL
MMM4537
735
945
$OVI
480
LIMC
LEMD
23B
NIL
NIL
$
NIL
$
$
$
$
$
[/TABLE]
Re: Sorting Data based on Dep Time and Reg Code using VB code
Quote from excellover2012;606559Hello Jindon,
Agian facing sorting problem when the A2 is blank :
Can you upload a file?
Picture doesn't help.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Thanks , Here is a sample.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Change GetDups to
Private Sub GetDups()
Dim r As Range, w()
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For Each r In Range("a2", Range("a" & Rows.Count).End(xlUp))
If r.Value <> "" Then
r.Value = Split(r.Value, "-")(0)
If Not .exists(r.Value) Then
.Item(r.Value) = VBA.Array(r(, 6).Value, r(, 7).Value, r.Row, 64)
Else
w = .Item(r.Value)
If r(, 6).Value = w(0) Then
If w(0) = w(1) Then
w(3) = w(3) + 1
Cells(w(2), 1).Value = _
Cells(w(2), 1).Value & "-" & Chr(w(3))
w(1) = 0
.Item(r.Value) = w
End If
If r(, 6).Value = r(, 7).Value Then
w(3) = w(3) + 1
.Item(r.Value) = w
r.Value = r.Value & "-" & Chr(w(3))
End If
End If
End If
End If
Next
End With
End Sub
Display More
Re: Sorting Data based on Dep Time and Reg Code using VB code
Thank you, but what is the difference between the previous code and the new code.
I could not notice any difference between the two, what I was actually looking for is how to remove all the blank lines including the "$" signs and "nil" in those blank cells so that I can sort the data by Flight #, it's kind of separate code to only sort the data by Flight #.
Re: Sorting Data based on Dep Time and Reg Code using VB code
I am uploading the file with color code where the blank cells, if you try to sort it by Flight # , the $ sings first shows and then the data, I am trying to remove those blank cells altogether and sort them by Flight #.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Thank you,
See what happens when I try to sort the data by Flight #, it is sorting the blank cells including the $ and the blank nil and then at the end the database is sorted.
This is what I was trying to avoid , I want to sort the database by Flight # , but without the blank cells.
I am attaching a sample W/Sheet that has the codes.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Col.A of your file must contain invisible character.
How are you populating those cells?
Re: Sorting Data based on Dep Time and Reg Code using VB code
So change you Macro4 (sorting macro) to
Re: Sorting Data based on Dep Time and Reg Code using VB code
This is it Jindon, this does the trick , Thanks; I will try it on the real data and let you know.
Don’t have an account yet? Register yourself now and be a part of our community!