StanAalbers
Board Regular
- Joined
- Feb 5, 2008
- Messages
- 51
Dear all,
I have a code that is working, but it takes a lot of time with ± 6,000 rows and this is merely the test run...
Question is: is there a more efficient way and when not, can I make the actions invisible so that the user doesn't go into anaphylactic shock while the report is running...
Cells A12 - Q.... contains my table with shipment information. The user can select the following:
C4 = the appropriate center it needs to display (Validation list)
C6 = week nr
c8 = sort by (delivery accuracy, concerns etc.)
This is my code:
Additional comment I: can I combine the sorting with a choice between Ascending and Descending? Couldn't get that one to work...
Additional comment II: the bold statement is now static, but it didn't seem to work when I made it flexible as in the "select-code", don't know why.
Thx in advance
I have a code that is working, but it takes a lot of time with ± 6,000 rows and this is merely the test run...
Question is: is there a more efficient way and when not, can I make the actions invisible so that the user doesn't go into anaphylactic shock while the report is running...
Cells A12 - Q.... contains my table with shipment information. The user can select the following:
C4 = the appropriate center it needs to display (Validation list)
C6 = week nr
c8 = sort by (delivery accuracy, concerns etc.)
This is my code:
Code:
Sub sort()
'Hide all the rows
Range("13:65536").EntireRow.Hidden = False
Dim c As Long
Select Case UCase(Range("c8").Value)
Case "CLAIMS"
c = 13
Case "DELIVERY ON TIME"
c = 14
Case "P/U CONCERNS"
c = 15
Case Else
c = 16
End Select
If c > 0 Then
Range("a12:p" & Cells(Rows.Count, "A").End(xlUp).Row).sort Key1:=Cells(2, c), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, Orientation:=xlTopToBottom
End If
hide_unwanted
End Sub
Sub hide_unwanted()
Range("13:65536").EntireRow.Hidden = True
'Hide all the rows that are not part of this center
Dim center As Range
[B]Set center = Range("Q12:Q6000")[/B]
For Each cell In center
If cell <> "" Then
If cell.Value = Range("c4") & Range("c6") Then
cell.EntireRow.Hidden = False
End If
End If
Next cell
End Sub
Additional comment I: can I combine the sorting with a choice between Ascending and Descending? Couldn't get that one to work...
Additional comment II: the bold statement is now static, but it didn't seem to work when I made it flexible as in the "select-code", don't know why.
Thx in advance