Macro-error 400- macro doesn't work on other computer

L

lunker55

I sent an excel workbook to another computer.
On that computer, I created a macro button and assigned the macro to it
(which is in "This Workbook"), but I get "400" error show up and the macro
doesn/t work.
Do I have the macro in the wrong place?

Joe
 
D

Dave Peterson

I seached the VBA help for "trappable errors" and found this for 400:

Form already displayed; can't show modally (Error 400)

You can't use the Show method to display a visible form as modal. This error has
the following cause and solution:

You tried to use Show, with the style argument set to 1 – vbModal, on an already
visible form.
Use either the Unload statement or the Hide method on the form before trying to
show it as a modal form.


===
Does this jog your memory? If not, you may want to post your code (not the
workbook)--and if possible, the offending line.
 
L

lunker55

That doesn't seem to be my problem. This is the code. Macro3 is a recorded
macro.

Joe

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 Macro3()
'
' Macro3 Macro
' Macro recorded 16/04/2004 by joe c
'

'
Rows("3:2715").Select
Selection.Sort Key1:=Range("B3"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ActiveWindow.ScrollRow = 3
Range("B5").Select
End Sub


Sub start_all()
Macro3
Delete_Blank_Rows
insert_rows
End Sub
 
D

Dave Peterson

I put some test data on a worksheet and ran your code.

It worked ok for me in simple testing. You're not using any userforms?

What line gives the error when your code breaks?
 
Top