ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel Macro (https://www.excelbanter.com/excel-discussion-misc-queries/184211-excel-macro.html)

nicolaux

Excel Macro
 
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

joel

Excel Macro
 
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

"nicolaux" wrote:

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



All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com