I have created a macro that runs fine on my Windows 8.1 PC with Excel 2013. My client has Excel 2013 on a Windows 7 PC. She is receiving a Run-Time error 1004 Select method of Worksheet class failed.
I have checked both the Excel Add-Ins and References in Excel and VBA and have even had her re-install Office 365 without success.
The macro runs on every other computer that we've tried it on.
The line of code causing the problem is: Worksheets("Summary").select Originally the line was ws.main.activate but then that line caused the break so I commented that line out and added the select line. There is definitely a worksheet named Summary. The
Sheet is protected at this point but the workbook is not.
The code is below and I've underlined and italicized the relevant line. The code is in the ThisWorkbook section as is triggered by the Workbook_Open event.
I would greatly appreciated any help in resolving this issue.
Private Sub Workbook_Open()
Dim wsMain As Worksheet, wsFr As Worksheet
Dim YN As Integer, Reg As Boolean, X As Integer
Set wsMain = Worksheets("Summary")
If IsEmpty(wsMain.Range("b4")) = True Then
YN = MsgBox("It looks like you are ready to setup a Market Survey file" & Chr(10) & _
"for a new property. Would you like to create a sheet for your" & Chr(10) & _
"subject property now?", vbInformation + vbYesNo, "New Survey File")
If YN <> vbYes Then Exit Sub
If YN = vbYes Then
OrderWorksheets
AddNewComp True
wsMain.Unprotect PW
With wsMain.Range("b4")
.Interior.ColorIndex = 10
.Font.ColorIndex = 2
End With
wsMain.Protect Password:=PW, Contents:=True, Scenarios:=True
End If
End If
Set wsFr = Worksheets("Formulas")
Reg = False
For X = 1 To wsFr.Range("n1").End(xlDown).Row
If Application.UserName = wsFr.Range("n" & X).Value Then
Reg = True
Exit For
End If
Next
' wsMain.Activate
Worksheets("Summary").Select
wsMain.Unprotect PW
Select Case Reg
Case Is = True
ActiveSheet.Shapes("Button 2").Select
Selection.Characters.Text = "Submit to Corporate"
Selection.OnAction = "SubmitToCorporate"
Case Is = False
ActiveSheet.Shapes("Button 2").Select
Selection.Characters.Text = "Submit to Regional"
Selection.OnAction = "SubmitToRegional"
End Select
wsMain.Protect PW
Range("b5").Select
End Sub