Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Programatically deleting Range

Hi Grant,

Thanks to all who have responded. I've pretty much got the answer I needed
and scripted my code accordingly. There's only one problem....... After
running the code repeatedly, clicking on the Insert - Name - Define Menu
reveals defined names "Server1_Detail_1", "Server1_Detail_2",
"Server1_Detail_3" etc etc all with the similar invalid references ie
=Sheet2!#REF!.


LIke this:

Sub DeleteAllQueries()
Dim qt As QueryTable
Dim WSh As Worksheet
Dim strQueryName
Dim oName as Name
For Each WSh In ThisWorkbook.Worksheets
strQueryName = WSh.Range("D2")
For Each qt In WSh.QueryTables
If InStr(qt.Name, strQueryName) Then
qt.ResultRange.ClearContents
qt.ResultRange.Delete
qt.Delete
End If
for each oName in Activeworkbook.Names
If Instr(oName.Name,strQueryname) Then
oName.Delete
End If
Next oName
Next qt
Next WSh

End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting or changing a range name Dan Excel Discussion (Misc queries) 3 April 21st 06 10:53 PM
Deleting Range name's listed in the range address box. Satnam Patel Excel Discussion (Misc queries) 4 May 5th 05 01:42 PM
Deleting range names CiaraG[_4_] Excel Programming 1 May 10th 04 04:39 PM
Rename a Range, programatically? plh[_2_] Excel Programming 0 September 4th 03 05:11 PM
Deleting range not a row Robert[_13_] Excel Programming 3 September 1st 03 11:12 PM


All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"