ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning a file name after checking for specific character (https://www.excelbanter.com/excel-programming/419399-returning-file-name-after-checking-specific-character.html)

Wendy

Returning a file name after checking for specific character
 
Hi,
I need to return the first set of characters before an underscore in a
filename. slightly disappointed as I can't do this:

FName = Chr$(34) & Left(ActiveWorkbook.Name, Search(Chr$(95),
ActiveWorkbook.Name)) & Chr$(34)

How else can I do it, apart from using another workbook cells to return the
activeworkbookName and then using the len and search function....this is part
of a loop of many workbooks.

Many thanks
Wendy

Mike H

Returning a file name after checking for specific character
 
Weny,

Use the Instr function

FName = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, "_") - 1)

Mike

"Wendy" wrote:

Hi,
I need to return the first set of characters before an underscore in a
filename. slightly disappointed as I can't do this:

FName = Chr$(34) & Left(ActiveWorkbook.Name, Search(Chr$(95),
ActiveWorkbook.Name)) & Chr$(34)

How else can I do it, apart from using another workbook cells to return the
activeworkbookName and then using the len and search function....this is part
of a loop of many workbooks.

Many thanks
Wendy


geoff_ness

Returning a file name after checking for specific character
 
Try
FName = Left$(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, Chr
$(95)) - 1)

HTH

On Nov 1, 8:58*pm, Wendy wrote:
Hi,
I need to return the first set of characters before an underscore in a
filename. slightly disappointed as I can't do this:

FName = Chr$(34) & Left(ActiveWorkbook.Name, Search(Chr$(95),
ActiveWorkbook.Name)) & Chr$(34)

How else can I do it, apart from using another workbook cells to return the
activeworkbookName and then using the len and search function....this is part
of a loop of many workbooks.

Many thanks
Wendy



Wendy

Returning a file name after checking for specific character
 
Thanks Mike, forgot about InStr...
Cheers
Wendy

"Mike H" wrote:

Weny,

Use the Instr function

FName = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, "_") - 1)

Mike

"Wendy" wrote:

Hi,
I need to return the first set of characters before an underscore in a
filename. slightly disappointed as I can't do this:

FName = Chr$(34) & Left(ActiveWorkbook.Name, Search(Chr$(95),
ActiveWorkbook.Name)) & Chr$(34)

How else can I do it, apart from using another workbook cells to return the
activeworkbookName and then using the len and search function....this is part
of a loop of many workbooks.

Many thanks
Wendy


Mike H

Returning a file name after checking for specific character
 
Glad I could help

"Wendy" wrote:

Thanks Mike, forgot about InStr...
Cheers
Wendy

"Mike H" wrote:

Weny,

Use the Instr function

FName = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, "_") - 1)

Mike

"Wendy" wrote:

Hi,
I need to return the first set of characters before an underscore in a
filename. slightly disappointed as I can't do this:

FName = Chr$(34) & Left(ActiveWorkbook.Name, Search(Chr$(95),
ActiveWorkbook.Name)) & Chr$(34)

How else can I do it, apart from using another workbook cells to return the
activeworkbookName and then using the len and search function....this is part
of a loop of many workbooks.

Many thanks
Wendy



All times are GMT +1. The time now is 02:01 PM.

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