Friday, March 2, 2012

To open Excel or CSV from another Excel macro

Here is the code:

Filt = "Excel Files (*.xlsx),*.xlsx,Excel Files (*.xls),*.xls"
FilterIndex = 5
Title = "File 1"
Filename = Application.GetOpenFilename(FileFilter:=Filt, _
FilterIndex:=FilterIndex, Title:=Title)
 Workbooks.Open (FileName)



 To get the file name


P = WorksheetFunction.Substitute(FileName, Left(FileName, InStrRev(FileName, "\")), "")

No comments:

Post a Comment