FalconFlyer
New Member
- Joined
- May 18, 2015
- Messages
- 30
I need some help troubleshooting an error. I have an spreadsheet with some code and it runs with no errors. I saved it and opened it the next day and got the "Excel found unreadable content. do you want to recover the contents?". It then states "Removed Records: Sorting from /xl/worksheets/sheet4.xml part". I looked in VBE and I do not have a Sheet4. Even with this removed, the code seems to work fine, but I'd like to resolve the error. I am assuming the problem is with the sorting code. I used the macro recorder to help, so I am not sure why it is wrong. Any advice would be appreciated. TIA.
<code>
</code>
<code>
Code:
Sub RunAll()
'
' Macro2 Macro
'
'
Application.ScreenUpdating = False
Worksheets("Data").Visible = True
Sheets("Dataset").Select
Cells.Select
Selection.ClearContents
Range("A1").Select
Sheets("Data").Select
Range("Table_Query_from_IQS[#All]").Select
Selection.Copy
Sheets("Dataset").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Worksheets("Data").Visible = False
'Sort before cleaning data
LastRow = Range("A" & Rows.Count).End(xlUp).Row
With Sheets("Dataset").Sort
.SortFields.Add Key:=Range("A1"), Order:=xlAscending
.SortFields.Add Key:=Range("M1"), Order:=xlAscending
.SetRange Range("A1:U" & LastRow)
.Header = xlYes
.Apply
End With