Run Time Error 13 in one WB but not the other

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello all,

I am getting a run time error 13 in one particular workbook, but not another. I'm not entirely sure what could have changed, but I know its not the code in the sub. I copied the same code from another workbook that the code is functioning properly and resulted in the same issue. If anybody can give me any ideas as to what would cause this, I would greatly appreciated it.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
My guess (as you haven't given us much to go on) is that your code is trying to use a cell value where the cell actually contains an error value, e.g. #N/A or #DIV/0!

But there are other possibilities.

Can you post your code and let us know which line is giving the error message?
 
Upvote 0
Heres the code: Red line is where it stops

Code:
Private Sub Term()Application.ScreenUpdating = False
Application.Run "module5.destructure"
Dim msg, Style, Title
Dim oPrevSelection As Range
Dim rw As Long
rw = ActiveCell.Row
ActiveSheet.Unprotect "password"
Range(Cells(ActiveCell.Row, "C"), Cells(ActiveCell.Row, "D")).Select


Set oPrevSelection = Selection
Selection.Copy
Range("N1").PasteSpecial xlPasteValues


msg = ("Are you sure you want to get rid of " & Sheets("Employees").Range("N1").Value & " " & Sheets("Employees").Range("O1").Value & "?")
Style = vbYesNo + vbExclamation
Title = "Let's Think This Through..."
[COLOR=#ff0000]Response = MsgBox(msg, Style, Title, help, Ctxt)[/COLOR]
If Response = vbNo Then
    MyString = "No"
    Exit Sub
Else
    MyString = "Yes"
    
End If
'need to find 'Master Availability' reference and clear
    Sheets("Terminated").Visible = True
    Sheets("Terminated").Select
    ActiveSheet.Unprotect "password"
    Sheets("Employees").Select
    oPrevSelection.Select
 'could dim values of current cells to establish the employee's name - this method still works though
    Range(Cells(ActiveCell.Row, "C"), Cells(ActiveCell.Row, "L")).Select
    Selection.Copy
    Worksheets("Terminated").Select
    lMaxRows = Cells(Rows.Count, "B").End(xlUp).Row
    Range("B" & lMaxRows + 1).PasteSpecial xlPasteValues
    Intersect(Columns("A"), Selection.EntireRow).Select
    With Selection
    .Value = Date
    .NumberFormat = "mm/dd/yy"
    End With
    'go to column A of current row
    'insert current date
    
    Sheets("Employees").Select
    oPrevSelection.Select
    Range(Cells(ActiveCell.Row, "C"), Cells(ActiveCell.Row, "S")).Select
    'Selection.Copy
    With Selection
    .ClearContents
    End With
    Sheets("Terminated").Select
    
    Range(Cells(ActiveCell.Row, "C"), Cells(ActiveCell.Row, "B")).Select
    Selection.Copy
    Range("N1").PasteSpecial xlPasteValues
    Sheets("Terminated").Select
    ActiveSheet.Protect "password"
    Sheets("Employees").Select
    
    ActiveSheet.Protect "password", _
    DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=True, AllowFormattingColumns:=True, _
        AllowFormattingRows:=True




Sheets("Master Availability").Visible = True
Sheets("Master Availability").Range("E" & rw + 83).Resize(1, 15).Interior.Color = xlNone
Sheets("Master Availability").Range("E" & rw + 83).Resize(1, 15).ClearContents


Sheets("Employees").Select
Sheets("Master Availability").Visible = xlSheetVeryHidden
    Range("E1").Activate
    MsgBox (Sheets("Terminated").Range("N1").Value & " " & Sheets("Terminated").Range("O1").Value & " has been terminated."), vbInformation, "A Message from the Terminator..."


Application.Run "module5.structure"
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Have you declared the variables help and Ctxt somewhere else in your code?

What values do they have?

(MsgBox is expecting string and numeric respectively).
 
Upvote 0
Thank you. I had those same variables and once I altered the names, they worked perfectly!
 
Upvote 0

Forum statistics

Threads
1,215,924
Messages
6,127,725
Members
449,401
Latest member
TTXS

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