rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 574
- Office Version
- 365
- Platform
- Windows
I have a macro that is called from another macro that when it runs I get the following error message:
------------------------------
Run-Time error '1004':
Unable to set the Visible property of the Worksheet class
-------------------------------
Then it flags the line in red in the first code box below:
The macro runs, brings me to the main page, hides the other worksheets, and completes everything else written, and then it flags the error. I don't know what to look for or how to resolve it.
Thanks in advance for any help with this bug, I mean design feature!
Robert
-----------------------------------------
The above macro gets called from this macro.
The other macros listed appear below.
------------------------------
Run-Time error '1004':
Unable to set the Visible property of the Worksheet class
-------------------------------
Then it flags the line in red in the first code box below:
The macro runs, brings me to the main page, hides the other worksheets, and completes everything else written, and then it flags the error. I don't know what to look for or how to resolve it.
Thanks in advance for any help with this bug, I mean design feature!
Robert
-----------------------------------------
Rich (BB code):
Sub Intro_page()
Application.ScreenUpdating = False
On Error Resume Next
For Each s In Worksheets
s.Visible = False
If s.Name = "Intro Page" Then s.Visible = True
Next s
Sheets("Intro Page").Activate
With ActiveWindow
.ScrollColumn = 1
.ScrollRow = 1
End With
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
Rich (BB code):
Sub MSTS_UPDATE_CHECK_EXIT()
'Check to see if main field says 'YES' and Line # is Blank
If Range("BE7").Value = "YES" And Range("BE5") = "" Then
Call MSTS_MAIN_Update
End If
If Range("BE14").Value = "YES" And Range("BF14") = "" Then
Call MSTS_T12_Update
End If
If Range("BE15").Value = "YES" And Range("BF15") = "" Then
Call MSTS_T18_Update
End If
If Range("BE16").Value = "YES" And Range("BF16") = "" Then
Call MSTS_T24_Update
End If
Call Intro_page
End Sub
Rich (BB code):
Sub MSTS_MAIN_Update()
' Ask user if they want to update the Master Stability Tracking Sheet.
Application.EnableEvents = False
i = MsgBox("Do you want to update the Master Stability Tracking Sheet?", vbYesNo + vbExclamation + vbDefaultButton2)
If i = 7 Then 'NO
Application.EnableEvents = True
Application.ScreenUpdating = True
Call Intro_page
Exit Sub
ElseIf i = 6 Then 'YES
Application.ScreenUpdating = False
File1 = ActiveWorkbook.Name 'defines the current workbook name as File1
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BD11:BO11").Copy
'open Master Stability Tracking Sheet workbook
ChDir "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data"
Workbooks.Open Filename:= _
"\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data\Master Stability Tracking Sheet.xlsm"
' Check to see if first row is blank and if it is paste data in first row.
If Range("B4").Value = "" Then
Range("B4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' If first row is not blank, go to the first empty row.
Else
Range("B3").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End If
' transfer row number back to the main workbook.
Range("B3").End(xlDown).Offset(0, -1).Copy 'From MSTS trendline workbook
With Workbooks(File1)
.Sheets("QC5003.8 PCB Stab Rec - Storage").Visible = True
.Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BE5").PasteSpecial Paste:=xlPasteValues
End With
ActiveWorkbook.Save
ActiveWorkbook.Close ' close MSTS workbook
Workbooks(File1).Activate
' record the date MSTS was updated.
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("AH31").Value = Date
Sheets("QC5003.8 PCB Stab Rec - Storage").Visible = False
Application.EnableEvents = True
Application.ScreenUpdating = True
Call Intro_page
MsgBox "Data transfer is complete."
End If
End Sub
Rich (BB code):
Sub MSTS_T12_Update()
Application.ScreenUpdating = False
File1 = ActiveWorkbook.Name
ChDir "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data"
Workbooks.Open Filename:= _
"\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data\Master Stability Tracking Sheet.xlsm"
Range("Z1").ClearContents
Workbooks(File1).Activate
Sheets("QC5003.8 PCB Stab Rec - Storage").Visible = True
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BE5").Copy
Application.ScreenUpdating = True
Workbooks("Master Stability Tracking Sheet.xlsm").Activate
Application.ScreenUpdating = False
Sheets("Stability").Range("Z1").PasteSpecial Paste:=xlPasteValues
'Loop to find row
Range("A3").Select
Do
If ActiveCell.Value <> Range("Z1").Value Then
Selection.Offset(1, 0).Select
End If
Loop Until ActiveCell.Value = Range("Z1").Value
ActiveCell.Offset(0, 13).Select
ActiveCell.Value = Date
ActiveWorkbook.Save
ActiveWorkbook.Close
Workbooks(File1).Activate
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BF14").Value = Date
Application.ScreenUpdating = True
Call Intro_page
End Sub
Rich (BB code):
Sub MSTS_T18_Update()
Application.ScreenUpdating = False
File1 = ActiveWorkbook.Name
ChDir "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data"
Workbooks.Open Filename:= _
"\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data\Master Stability Tracking Sheet.xlsm"
Range("Z1").ClearContents
Workbooks(File1).Activate
Sheets("QC5003.8 PCB Stab Rec - Storage").Visible = True
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BE5").Copy
Application.ScreenUpdating = True
Workbooks("Master Stability Tracking Sheet.xlsm").Activate
Application.ScreenUpdating = False
Sheets("Stability").Range("Z1").PasteSpecial Paste:=xlPasteValues
'Loop to find row
Range("A3").Select
Do
If ActiveCell.Value <> Range("Z1").Value Then
Selection.Offset(1, 0).Select
End If
Loop Until ActiveCell.Value = Range("Z1").Value
ActiveCell.Offset(0, 14).Select
ActiveCell.Value = Date
ActiveWorkbook.Save
ActiveWorkbook.Close
Workbooks(File1).Activate
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BF15").Value = Date
Application.ScreenUpdating = True
Call Intro_page
End Sub
Rich (BB code):
Sub MSTS_T24_Update()
Application.ScreenUpdating = False
File1 = ActiveWorkbook.Name
ChDir "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data"
Workbooks.Open Filename:= _
"\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\PCB QC Trendline Data\Master Stability Tracking Sheet.xlsm"
Range("Z1").ClearContents
Workbooks(File1).Activate
Sheets("QC5003.8 PCB Stab Rec - Storage").Visible = True
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BE5").Copy
Application.ScreenUpdating = True
Workbooks("Master Stability Tracking Sheet.xlsm").Activate
Application.ScreenUpdating = False
Sheets("Stability").Range("Z1").PasteSpecial Paste:=xlPasteValues
'Loop to find row
Range("A3").Select
Do
If ActiveCell.Value <> Range("Z1").Value Then
Selection.Offset(1, 0).Select
End If
Loop Until ActiveCell.Value = Range("Z1").Value
ActiveCell.Offset(0, 15).Select
ActiveCell.Value = Date
ActiveWorkbook.Save
ActiveWorkbook.Close
Workbooks(File1).Activate
Sheets("QC5003.8 PCB Stab Rec - Storage").Range("BF16").Value = Date
Application.ScreenUpdating = True
Call Intro_page
End Sub