K
KimberlyC
Hi,
I'm using the following code to add 4 worksheets from another worksheet to
the active workbook.
It works great..unitl I change the Workbook name to the addin file name of
"WCAddin.xla"...which is how I need to run that file.
I get a Run Time Error --Application- defined or object defined error
message.
Is this due to me changing the workbook file name to xla vs xls?
If yes.. how would I rewrite the code to work with the addin file instead?
Public Sub AddWStoWCTemplate()
Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments", "Details",
"Calculations")).Copy After:=ActiveWorkbook.Worksheets(Worksheets.Count)
With ActiveWorkbook
For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
With Worksheets(i)
.Range("A1").Formula = .Range("A1").Value
.Range("A2").Formula = .Range("A2").Value
.Range("A3").Formula = .Range("A3").Value
End With
Next
End With
End Sub
I'm using the following code to add 4 worksheets from another worksheet to
the active workbook.
It works great..unitl I change the Workbook name to the addin file name of
"WCAddin.xla"...which is how I need to run that file.
I get a Run Time Error --Application- defined or object defined error
message.
Is this due to me changing the workbook file name to xla vs xls?
If yes.. how would I rewrite the code to work with the addin file instead?
Public Sub AddWStoWCTemplate()
Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments", "Details",
"Calculations")).Copy After:=ActiveWorkbook.Worksheets(Worksheets.Count)
With ActiveWorkbook
For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
With Worksheets(i)
.Range("A1").Formula = .Range("A1").Value
.Range("A2").Formula = .Range("A2").Value
.Range("A3").Formula = .Range("A3").Value
End With
Next
End With
End Sub