Renaming sheets with part of original name

  • Thread starter Thread starter MichaelR
  • Start date Start date
M

MichaelR

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top