Gingertrees
Well-known Member
- Joined
- Sep 21, 2009
- Messages
- 697
No idea what changed, but now this gets stuck at the Copy after line. Throws Runtime Error 13: Type Mismatch.
Could someone let me know WHY and help me fix it??? Thanks in advance. :
This is related to the code Norie helped me with recently (see http://www.mrexcel.com/forum/excel-...-end-copying-middle-second-place-instead.html). It worked then, but I've added and deleted other worksheets and certainly done other bad stuff since then.</type>
Could someone let me know WHY and help me fix it??? Thanks in advance. :
Rich (BB code):
Sub OpenCopyOrange()
'////Sub 1//////'////Sub 1//////'////Sub 1//////
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationAutomatic
Dim tempfiletocopy As Variant
Dim tempfileName As String
Dim tempsheet As Worksheet
Dim OrangeWb As Workbook
Set OrangeWb = ActiveWorkbook
tempfiletocopy = Application.GetOpenFilename
Workbooks.Open tempfiletocopy
tempfileName = ActiveWorkbook.Name
Set tempsheet = Workbooks(tempfileName).ActiveSheet
tempsheet.Name = "Orange"
Sheets("Orange").Copy After:=Workbooks(OrangeWb).Sheets(ThisWorkbook.Sheets.Count)
'////Info box appears stating: Workbooks(OrangeWb).Sheets(ThisWorkbook.Sheets.Count) = <type mismatch="">
'////
If Not SheetExists("Orange" & Sheets.Count) Then
ActiveSheet.Name = "Orange" & Sheets.Count
Else
ActiveSheet.Name = "Orange" & (Sheets.Count * 3)
End If
'///this prevents the "sheet name exists" error
Workbooks(tempfileName).Close savechanges:=False
'///closes file the new sheet was copied from
Application.ScreenUpdating = True
Application.DisplayAlerts = True
'//reset the speed tricks
End Sub
This is related to the code Norie helped me with recently (see http://www.mrexcel.com/forum/excel-...-end-copying-middle-second-place-instead.html). It worked then, but I've added and deleted other worksheets and certainly done other bad stuff since then.</type>