Hi,
I am doing a sort on a some data in sheet
I have around 9 columns for sorting.
When i do sorting I repopulate the description column again, bcoz it is a lookup to hidden sheet, so whenever sorting is done , i repopulate the formula again in the cells.
Now, I feel the performance is little slow and also my screen flickers when i click the header column for sort. I have disabled ScreenUpdating,EnableEvents,displayAlerts..but still it flickers..
I would appreciate if anybody could help on this!!!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Wk As Worksheet
Dim wSht As Worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Set Wk = Sheets(HiddenSheetName)
If Target.Cells.Row = 6 Then
CostUpload.UnprotectSheet DailyCostsSheetName, ActiveWorkbook
If Target.Cells.Column = Range("D.ReportDate").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.ReportDate"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.AccountCode").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.AccountCode"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.DailyCost").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.DailyCost"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.Description").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.Description"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.AFENo").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.AFENo"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.Vendor").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.Vendor"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.Notes").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.Notes"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.FinalTicket").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.FinalTicket"), Order1:=xlAscending
End If
If Target.Cells.Column = Range("D.TicketNO").Column Then
Range("D.TotalRange").Sort Key1:=Range("D.TicketNO"), Order1:=xlAscending
End If
Set wSht = ActiveWorkbook.Sheets(DailyCostsSheetName)
For i = 7 To Wk.Range(RNoofRecords).Cells.Value + 7 - 1
s = "=Lookup(" & wSht.Cells(i, Range("D.AccountCode").Column).Address & "," & HiddenSheetName & "!" & Wk.Range(RCostCode).Address & "," & HiddenSheetName & "!" & Wk.Range(RCostCodeDescription).Address & ")"
Cells(i, wSht.Range("D.Description").Column).Formula = s
Next i
ActiveWorkbook.Saved = True
CostUpload.ProtectSheet DailyCostsSheetName, ActiveWorkbook
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End If
End If
End Sub
Thanks
Bookmarks