Excel Macro

N

nicolaux

Hi All,

I need a simple macro that fill a cell of an excel sheet with some
data that comes from the file name.

Example:

If the file name is 35.xls the cell(B,2) contains the text "35".



Thanks a lot
Nicola
 
J

Joel

Sub test()

Folder = "C:\temp"
FName = "35.xls"

Workbooks.Open Filename:=Folder & "\" & FName
FNumber = Val(Left(FName, InStr(FName, ".") - 1))
Range("B2") = FNumber

End Sub
 

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

Top