View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
EdStevens EdStevens is offline
external usenet poster
 
Posts: 7
Default question regarding external data range

That gave me what I needed. Thanks for the help.

"affordsol" wrote:

Hello,

You'll find below some code which should help you ... someway.

Glad to help+


'===ROUTINES===ROUTINES===ROUTINES===ROUTINES===RO UTINES
Sub ShowAllNamedRanges()
Dim lngNamesCount As Long
Dim intPtr As Integer
Dim strNamedRanges As String

'Get the nr of named ranges
lngNamesCount = Application.Names.Count
'Empty the strNamedRanges text
strNamedRanges = ""
For intPtr = 1 To lngNamesCount
strNamedRanges = strNamedRanges & vbCrLf & intPtr & " = " &
Names(intPtr).Name
Next intPtr
MsgBox strNamedRanges
End Sub
'===ROUTINES===ROUTINES===ROUTINES===ROUTINES===RO UTINES
Sub DeleteOneNamedRange()
Dim lngNamesCount As Long
Dim intPtr As Integer
Dim strNamedRanges As String

'Get the nr of named ranges
lngNamesCount = Application.Names.Count
'Empty the strNamedRanges text
strNamedRanges = ""
'Put list of Named Ranges in strNamedRanges
For intPtr = 1 To lngNamesCount
strNamedRanges = strNamedRanges & vbCrLf & intPtr & " = " &
Names(intPtr).Name
Next intPtr

Dim strPrompt, strTitle, strDefault, strConfirm As String
Dim intIndexOfRangeToBeDeleted As Integer
strTitle = "Delete one Named Range"
strDefault = ""
strPrompt = strNamedRanges & vbCrLf & "Input the index of the Named Range
to be deleted ..."
intIndexOfRangeToBeDeleted = Val(InputBox(strPrompt, strTitle, strDefault))

If intIndexOfRangeToBeDeleted 0 Then
strTitle = strTitle & " CONFIRM..."
strPrompt = "DELETE " & Names(intIndexOfRangeToBeDeleted) & vbCrLf &
"<Yes or <No..."
strConfirm = InputBox(strPrompt, strTitle, strDefault)
If Left(strConfirm, 1) = "Y" Then
Names(intIndexOfRangeToBeDeleted).Delete
End If
End If
End Sub
'===ROUTINES===ROUTINES===ROUTINES===ROUTINES===RO UTINES
--
Herve Hanuise
http://www.affordsol.be


"EdStevens" wrote:

Excel 2003 on XP Pro

Every day I receive a text file with a single record (space delimited). I
have written a macro to load that record into the next row of the worksheet,
using Get External Data. All that is working fine, but in doing initial
testing and debugging of the macro, I noticed that every time I bring in a
new record, it creates a new external data range. I really don't need these
defined data ranges, I just need the values loaded in. Really just a
housekeeping issue ... several months from now, when I have 100+ rows of
data, do I really want to have 100+ different external data ranges defined?
Or am I obsessing about a non-issue? Is there some way to clean-up/delete
the range definitions without deleting the data (cell values) itself?