LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default New Named Range Created Each Time Data Imported into Excel via Macro

I recorded a macro that imports data into a sheet. I am finding that
each time I run this macro, a new named range is added to the list of
named ranges. Does anyone know why this is happening, and how I can
stop this action? This does not create a problem per se; it's just
that the list of names gets longer and longer.

Each new named range is for the same range, since I always import to
the same sheet/range. Each time the macro is run, the name has a
number at the end of the name that is incremented, e.g., receipt_20,
receipt_21, etc.

The recorded VBA looks like this:

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;K:\usrfiles\download\receipt.txt",
Destination:=Range("recpts!A2"))
.Name = "receipt"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 3
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 2, 2, 3, 1, 1)
.TextFileFixedColumnWidths = Array(2, 1, 2, 10, 13)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

I tried commenting out the line with .Name in front, but it still
created a new named range.

Thanks,

Carroll Rinehart
 
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
Named Range DTS Import of Excel Data Harold I Excel Discussion (Misc queries) 0 September 28th 07 05:38 PM
Formatting time from imported data Wanna Learn Excel Discussion (Misc queries) 3 June 15th 07 07:52 PM
Named Range changes when data is imported Matt7102 Excel Discussion (Misc queries) 1 August 28th 06 10:03 PM
Macro run each time a new workbook created cmorton89 Excel Discussion (Misc queries) 0 March 8th 06 07:58 PM
Outlook wants an Excel named range to import contact data why? GDB026 Excel Discussion (Misc queries) 1 December 16th 05 04:59 PM


All times are GMT +1. The time now is 10:40 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"