Re: Sorting Data based on Dep Time and Reg Code using VB code
Hello Jindon, I tested it on actual data and it works perfect, many thanks, really appreciated.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Hello Jindon, I tested it on actual data and it works perfect, many thanks, really appreciated.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Quote from jindon;606657So change you Macro4 (sorting macro) to
Hello Jindon,
If you remember the above code you gave me , this actually sorts the data by flight number disregarding the hidden value in column A , I need to do many sorting ligics ( e.g I want to sort the data by "Trip No. 2" and "Dep Time" ( the earliest first ), this hidden value in column is messing up my data.
Is there any code that I can insert in any module so that before I run any sorting , 1st the hidden values in column A are removed then the sorting done without considering any blank or $ or NIL vlaues in the blank cells?
Thanks.[TABLE="width: 81"]
[/TABLE]
Re: Sorting Data based on Dep Time and Reg Code using VB code
Replace Sheets("Sheet1") with ActiveSheet.
Re: Sorting Data based on Dep Time and Reg Code using VB code
But, the above code only sorts the data by Flight No. am I right?
Re: Sorting Data based on Dep Time and Reg Code using VB code
The follwoing part is cleaning your data
With .UsedRange.Columns(1)
.Value = Evaluate("if(" & .Address & "<>"""",trim(clean(" _
& .Address & ")),"""")")
End With
And the rest is the sort part.
Once it is cleaned, no need to run the code, so sort the data as you like.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Thanks, I will try it and let you know.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Hello Again jindon, Thank you for your help,
I have been busy testing the code using different scenarios, I thought the code will actually remove those blank cells , but it does not. it would very much help if the code can actually delete/remove all the blank cells .
Is it possible?
Re: Sorting Data based on Dep Time and Reg Code using VB code
try
Sub Macro4()
With Sheets("Sheet1")
With .UsedRange.Columns(1)
.Value = Evaluate("if(" & .Address & "<>"""",trim(clean(" _
& .Address & ")),"""")")
End With
.Rows(.Range("a" & Rows.Count).End(xlUp)(2).Row & ":" & Rows.Count).Clear
With .Range("a1", .Range("a" & Rows.Count).End(xlUp)).Resize(, 10)
.Sort .Range("a1"), 1
End With
End With
End Sub
Display More
Re: Sorting Data based on Dep Time and Reg Code using VB code
Thanks Jindon, I will try it and let you kow.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Hello Jindon,
When I run the code , the MACRO freezez , I have to force stop it, any Idea why?
Thanks.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Can you upload the file?
I can not replicate the problem here.
Re: Sorting Data based on Dep Time and Reg Code using VB code
Thanks, I will soon.
Re: Sorting Data based on Dep Time and Reg Code using VBA
Hello Jindon , I tested the Code on a separate sheet and it is working , I will continue to see why it is not doing so in the real data.
Something came up in my company just today; they now decided to use a flight# and Reg Code as a trigger to distribute the data:- I know it is a challenge , but thank you for your help.
Here is a simple logic how it works:
a) Any Flight number range 20 – 2999 and range 9000 - 9099
1) with the first two Reg code $XP to be copied to Desk 1
2) with the first two Reg code $XQ to be copied to Desk 2
3) with the first two Reg code $XR to be copied to Desk 3
4) with the first two Reg code $XS to be copied to Desk 4
5) with the first two Reg code $XT to be copied to Desk 5
6) with the first two Reg code $XV to be copied to Desk 6
7) with the first two Reg code $XW to be copied to Desk 7
b) Any other Flight numbers with any Reg code other than the above , to be copied to Desk 8
I already created 8 sheets and named them Desk1 to 8.
DataBase
[TABLE="width: 0"]
Flight#
Dep Time
Arr Time
Reg Code
Pax Count
Dep Airport
Arr Airport
Class
Trip No.1
Trip No.2
MMM570
900
955
$XPSL
EGLL
EDDF
XX80
43000333
43000333
MMM9010
1600
1655
$XPSL
EDDF
EGLL
XX80
43000333
49000333
MMM6074
40
420
$XQD
480
LIRF
EGLL
23B
NIL
NIL
MMM7444
45
435
$XWI
446
LEMD
LIMC
23B
NIL
NIL
MMM3773
100
350
$XRX
EDDF
EGLL
22A
NIL
NIL
MMM733
120
735
$OXH
285
EDDK
EDDF
B70
NIL
NIL
MMM4860
511
540
$93S
LIRR
LIRR
123
NIL
NIL
MMM2900
600
945
$XST
433
LIMC
LIMJ
22A
NIL
NIL
MMM450
615
800
$XST
424
LIMJ
LIMC
22A
NIL
NIL
MMM2844
650
745
$XTX
EDDF
EGLL
B70
NIL
NIL
MMM4766
720
840
$OVD
480
EGLL
LIRF
23B
NIL
NIL
MMM4860
730
855
$XVV
465
LIRR
LIRF
123
NIL
NIL
MMM4537
735
945
$XQI
480
LIMC
LEMD
23B
NIL
NIL
$
NIL
$
$
$
$
$
[/TABLE]
Re: Sorting Data based on Dep Time and Reg Code using VBA
Can you upload a falie with your desired result?
And I suggest you to open a new thread as it seem to be different from your original question.
Re: Sorting Data based on Dep Time and Reg Code using VBA
Thanks Jindon,
I will open a new thread and upload a sample.
Re: Sorting Data based on Dep Time and Reg Code using VBA
I just posted a new thread called " Distributing data to multiple sheets based on 2 criteria "
Thank you again for your help, really appreciate it.
Don’t have an account yet? Register yourself now and be a part of our community!