|
-
Jan 16th, 2008, 01:32 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Open Worksheet from other book problem
Hey all,
On some occasions, I'm getting a warning message when opening a worksheet (found in another workbook) into my current workbook... The open still works fine, I'm just bothered by two warning messages that pop up.. and I can't figure out how to get rid of them.
the warning message reads: A formula or sheet you want to move or copy contains the name 'Leach', which already exists on the destination worksheet. Do you want to use this version of the name?
To use the name as defined in the destination sheet, click Yes.
To rename the range referred to in the formula or worksheet, click No, and enter a new name in the Name Conflict dialog box.
I don't ever remember naming a range in the saved sheet... Is there a way to check if I have any named ranges on a certain sheet? Or is there some code that can simply bypass this warning message? My code to open the sheet is as follows: Thanks much!
vb Code:
Application.DisplayAlerts = False
Dim sfilename As String
'Show the open dialog and pass the selected _
'file name To the String variable "sFileName"
sfilename = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", Title:=vNum)
'They have cancelled.
If sfilename = "False" Then Exit Sub
Dim temp As String
temp = spliceFileNameEnd2(sfilename)
For Each shtnext In Sheets
If shtnext.Name = "nindex" Then 'Search/Delete charts w/ same name
Application.DisplayAlerts = False 'No delete prompt
Sheets("nindex").Delete
Application.DisplayAlerts = True
End If
Next shtnext
Workbooks.Open FileName:=sfilename
Dim found As Boolean
found = False
For Each shtnext In Sheets
If shtnext.Name = "nindex" Then
found = True
Exit For
End If
Next shtnext
If found = False Then
Workbooks(temp).Close SaveChanges:=False
MsgBox ("No N-Index File was found in that file.")
Sheets.Add
ActiveSheet.Name = "nindex"
Exit Sub
End If
Sheets("nindex").Copy After:=Workbooks("NLEAPGIS10.xls").Sheets(ThisWorkbook.Sheets.Count)
Workbooks(temp).Close SaveChanges:=False
Application.DisplayAlerts = True
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|