View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Renaming sheets with part of original name

FName = ThisWorkbook.Name
Folder = ThisWorkbook.Path
'remove name before .xls
FName = Left(FName, Len(FName) - 4)
InFName = Folder & "\" & FName & ".Txt"


With ActiveSheet.QueryTables.Add(Connection:=InFName, _
Destination:=Range("A1"))

.Name = "FName"
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh BackgroundQuery:=False
End With


"MichaelR" wrote:

Hi,

I'm trying to write a macro that will import a sheet from a daily
computer-generated workbook into my excel file. The sheet that I want to
import has the same name as its workbook, which is a concatenation of a word,
the date that it was downloaded, and the time.

I would like to keep just the date. Is this possible and if so, how could I
write the code for it?

Thank you in advance for your time.