Corrupt file?

L

lunker55

I think our book might have been corrupted.
Last night when a user tried to organize(macro button to sort column A by
date) then save, the book froze.
We can view the book, but cannot use the macro.

The macros look the same as before.
Should I just delete them and re enter them?
Also, the book only goes down 400 rows and 10 columns, but when I hit CTRL +
END, it now goes to row 65554 and column W.

Joe
excel 2003

Sub insert_rows()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
For row_index = lastrow - 1 To 3 Step -1
If Cells(row_index, "B").Value <> Cells(row_index + 1, "B"). _
Value Then
Cells(row_index + 1, "B").Resize(2, 1).EntireRow. _
Insert (xlShiftDown)
Cells(row_index + 1, "B").Resize(2, 1).EntireRow. _
Interior.ColorIndex = 15
End If
Next
End Sub

Public Sub Delete_Blank_Rows()

Dim R As Long
Dim C As Range
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).EntireRow) = 0 Then
Rng.Rows(R).EntireRow.Delete
End If
Next R

EndMacro:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

Sub gregsort()
'
' gregsort Macro
' Macro recorded 5/18/2004 by Greg

Rows("3:3155").Select
Range("B3").Activate
Selection.Sort Key1:=Range("B3"), Order1:=xlAscending, Key2:=Range("F3")
_
, Order2:=xlAscending, Key3:=Range("C3"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("B1").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("B3").Select
End Sub



Sub start_all()
gregsort
Delete_Blank_Rows
insert_rows
End Sub
 
L

lunker55

Thank you so much Frank.
I was able to reset used range and now the macro works.
Could the problem be because my macro sorted down 20,000 rows, and the
workbook went down 65,5000?

Joe
 
F

Frank Kabel

Hi
could be the reason that the macro wasn't frozen but just took a huge
amount of time going through all rows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top