Screen goes white while sorting

gemini528

Board Regular
Joined
Jun 13, 2013
Messages
53
Hello Excel Gurus,

Whenever I the run code below, the screen goes white for 3 seconds (or until the sorting is done) then the normal black background. What I want is to eliminate the white background while sorting the data. Any suggestion or revision or addition on the code will be appreciated

Thank you very much.

Here is the code:
VBA Code:
Sub Sort()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
  With Sheets("INVTRY")
   .Unprotect Password:="password"
    With .Range("B4:F5000")
      .Cells.Sort Key1:=.Columns(Application.Match("TR DATE", .Rows(1), 0)), Order1:=xlAscending, _
                  Key2:=.Columns(Application.Match("ITEM NO", .Rows(1), 0)), Order2:=xlAscending, _
                  key3:=.Columns(Application.Match("DESC", .Rows(1), 0)), Order3:=xlAscending, _
                    Orientation:=xlTopToBottom, Header:=xlYes 'comma then space then underscore then ENTER key
    End With
   .Protect Password:="password", DrawingObjects:=False, UserInterfaceOnly:=True, Contents:=True, _
                           Scenarios:=True, AllowFiltering:=True, _
                           AllowFormattingCells:=True, AllowSorting:=True
  End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
 

gemini528

Board Regular
Joined
Jun 13, 2013
Messages
53
Thank you so much. It cures the sorting error. Will wait for your response on the me.Repaint.
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,053
Office Version
  1. 2019
Platform
  1. Windows
As far as i can see Me.Repaint is not valid for use with a worksheet / workbook. All of the examples that I've seen are for userforms.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,646
Messages
5,549,171
Members
410,903
Latest member
natesreich
Top