Odd Error - Once in a While

rconverse

Well-known Member
Joined
Nov 29, 2007
Messages
1,187
Hello,

I'm Receivng an error when I open a workbook:

Removed Records: Sorting from /xl/worksheets/sheet6.xml part

Any ideas as to what may be causing it? The workook is an xlsx workbook, so no macros/VBA. Although, a macro is used to create the workbook and there is a sort associated with that macro but that code is in a different workbook.

Thank you,
Roger

code that populates workbook in case relavent...

Code:
'remove data from dashboard for worksheet in current row
            wb1.Sheets(strWksName).Range("D2:BB500000").ClearContents
            wb1.Sheets(strWksName).Range("A3:C500000").ClearContents
            
            'open the workbook from which the data will be retreived
            Call OpenWb(strFilePath, strFileName)
            Set wb2 = Workbooks(strFileName)
            Set ws2 = wb2.Sheets(ws.Range("C" & c.Row).Value)
            Set ws1 = wb1.Sheets(ws.Range("H" & c.Row).Value)
            
            'find the last row of data to be retrieved
            FinalRow = ws2.Range("A" & Rows.Count).End(xlUp).Row
             
            'find the last column of data to be retrieved
             If strEndCol = "LAST" Or strEndCol = "last" Then
             
                'find column number and convert to letter
                FinalCol = ws2.Cells(1, ws2.Columns.Count).End(xlToLeft).Column
                strEndCol = Split(Cells(1, FinalCol).Address, "$")(1)
                
             End If
            
            'copy rows from source file into corresponding worksheet in dashboard
            ws2.Range("A2:" & strEndCol & FinalRow).Copy
            
            'paste data from source file into dashboard
            wb1.Sheets(strWksName).Range("D2").PasteSpecial xlPasteAll
            
            'sort
            wb1.Activate
            wb1.Sheets(strWksName).Range("D1:AD500000").Select
            ws1.Sort.SortFields.Add Key:=Range( _
            "D2:D" & FinalRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
            ws1.Sort.SortFields.Add Key:=Range( _
            "G2:G" & FinalRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
            ws1.Sort.SortFields.Add Key:=Range( _
            "O2:O" & FinalRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortNormal
            
                With ws1.Sort
                    .SetRange Range("D1:AD" & FinalRow)
                    .Header = xlYes
                    .MatchCase = False
                    .Orientation = xlTopToBottom
                    .SortMethod = xlPinYin
                    .Apply
                End With
            
            'copy formulas from a2:c2 down to the final row
            ws1.Range("A2:C2").Copy
            ws1.Range("A3:C" & FinalRow).PasteSpecial xlPasteFormulasAndNumberFormats
            ws1.Range("A1").Select
            
            'close source workbook
            wb2.Close
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Your macro never clears existing sort fields. You should use:

Code:
ws1.Sort.SortFields.clear

before the first line that adds a sortfield.
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top