Here is my issue:
Adding Option Explicit to my code module is causing an 'object needed' error when referencing named ranges within workbooks. Removing Option Explicit allows the code to run as expected. The line that errors out is Set Basewkst = [Criteria] where Criteria is the VBA name of a worksheet within the workbook.
Adding Option Explicit to my code module is causing an 'object needed' error when referencing named ranges within workbooks. Removing Option Explicit allows the code to run as expected. The line that errors out is Set Basewkst = [Criteria] where Criteria is the VBA name of a worksheet within the workbook.
Code:
Sub Update_SCD_Data()'Creates SCD Data sheet if it doesn't exist, then copies the data from the Data worksheet.
Dim ControlFile As String
Dim Dimen_Data_FileName As String
Dim DimenWbkName As String
Dim BaseWkst As Worksheet
Dim inputrng As Range
Dim destrng As Range
Dim SCDdata As Workbook
ControlFile = ActiveWorkbook.Name
If WorksheetExists("SCD Data") Then GoTo Clear_SCD_Table
'*****
Sheets("SUMMARY").Select
Sheets.Add After:=ActiveSheet
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "SCD Data"
'*****
Clear_SCD_Table:
Sheets("SCD Data").Select
If Last(1, Range("A:A")) < 4 Then GoTo RemoveSubtotals
Range("3:3").Select
With Range(Selection, Selection.End(xlDown)) _
.Offset(1, 0)
.Delete Shift:=xlUp
End With
RemoveSubtotals:
If InStr(ControlFile, "Asset") Then
Remove_SSB_Asset_Subtotals
ElseIf InStr(ControlFile, "Income") Then
Remove_SSB_Inc_Subtotals
End If
Sheets("SCD Data").Select
Set BaseWkst = [Criteria]
DimenWbkName = BaseWkst.[SCDWkbkName].Value
ChDir _
"\\accounting\Reconciliations\SCD - SSB Recons"
Workbooks.Open Filename:= _
"\\accounting\Reconciliations\SCD - SSB Recons\" & DimenWbkName _
, Notify:=False
Dimen_Data_FileName = ActiveWorkbook.Name
Application.Goto Reference:="SCDdata"
Set inputrng = Selection
Windows(ControlFile).Activate
Set destrng = Sheets("SCD Data").Range("A2:C2").Resize(inputrng.Rows.Count, inputrng.Columns.Count)
MsgBox ("destrng Address: " & destrng.Address)
destrng = inputrng.Value
Windows(Dimen_Data_FileName).Close False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub