Macro-copy and paste

L

lunker55

I copied and pasted a macro from one workbook to another, and when I use the
macro in the new book, it must open the old book to use the macro.

Is there something I have done wrong?
Joe
 
L

lunker55

I should also mention that the workbook is shared by two people.

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 Macro1()
'

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

Sub start_all()
Macro1
Delete_Blank_Rows
insert_rows
End Sub
 
L

lunker55

It seems to be working now. I think the macro buttons were pointing to the
macros in the old book. So I deleted all the macros and re-entered them in
the new book.

Joe
 
Top