Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Cell formula that captures name of the file's folder

Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell formula that captures name of the file's folder

Formulas at the bottom of this page

http://www.cpearson.com/excel/excelF.htm#SheetName

--
Regards,
Tom Ogilvy


"klysell" wrote:

Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Cell formula that captures name of the file's folder

Thanks Tom. These formulas are interesting, but they don't return the
"foldername", just the filename or the full path. How would I adapt this
formula to return the foldername in which the filename resides?

Thanks.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Tom Ogilvy" wrote:

Formulas at the bottom of this page

http://www.cpearson.com/excel/excelF.htm#SheetName

--
Regards,
Tom Ogilvy


"klysell" wrote:

Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell formula that captures name of the file's folder

based on the example you gave, i assumed by folder name that you meant the
tab name of the sheet. Nonetheless, you would just modify the formula to
get the folder name that the current file is saved in.

if the the cells("filename",A1) returns:

C:\AAAA_TOA\Toa_phase1\[Avenger_Stinger_DM.xls]Summary

then
=LEFT(CELL("filename",A1),FIND("[",CELL("Filename",A1))-1)

returns the path
C:\AAAA_TOA\Toa_phase1\

--
Regards,
Tom Ogilvy




"klysell" wrote:

Thanks Tom. These formulas are interesting, but they don't return the
"foldername", just the filename or the full path. How would I adapt this
formula to return the foldername in which the filename resides?

Thanks.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Tom Ogilvy" wrote:

Formulas at the bottom of this page

http://www.cpearson.com/excel/excelF.htm#SheetName

--
Regards,
Tom Ogilvy


"klysell" wrote:

Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Cell formula that captures name of the file's folder

Thanks. I decided to go another route.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Tom Ogilvy" wrote:

based on the example you gave, i assumed by folder name that you meant the
tab name of the sheet. Nonetheless, you would just modify the formula to
get the folder name that the current file is saved in.

if the the cells("filename",A1) returns:

C:\AAAA_TOA\Toa_phase1\[Avenger_Stinger_DM.xls]Summary

then
=LEFT(CELL("filename",A1),FIND("[",CELL("Filename",A1))-1)

returns the path
C:\AAAA_TOA\Toa_phase1\

--
Regards,
Tom Ogilvy




"klysell" wrote:

Thanks Tom. These formulas are interesting, but they don't return the
"foldername", just the filename or the full path. How would I adapt this
formula to return the foldername in which the filename resides?

Thanks.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Tom Ogilvy" wrote:

Formulas at the bottom of this page

http://www.cpearson.com/excel/excelF.htm#SheetName

--
Regards,
Tom Ogilvy


"klysell" wrote:

Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Cell formula that captures name of the file's folder

not sure what you're looking for, if the folder already exists or if you're
trying to create one.

this may give you the folder from which the workbook was opened.

Option Explicit
Sub test()
Dim fp As String
Dim fp2 As Variant
fp = ThisWorkbook.Path

fp2 = Split(fp, "\")
MsgBox fp2(UBound(fp2))
End Sub


--


Gary


"klysell" .(donotspam) wrote in message
...
Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Cell formula that captures name of the file's folder

Thanks Gary.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Gary Keramidas" wrote:

not sure what you're looking for, if the folder already exists or if you're
trying to create one.

this may give you the folder from which the workbook was opened.

Option Explicit
Sub test()
Dim fp As String
Dim fp2 As Variant
fp = ThisWorkbook.Path

fp2 = Split(fp, "\")
MsgBox fp2(UBound(fp2))
End Sub


--


Gary


"klysell" .(donotspam) wrote in message
...
Hi,

How does one capture the folder name in which a file resides? I want to
ensure that the folder name (in this case a date) is always indicated in a
cell in a spreadsheet. I could always use a pop-up calendar that the user can
enact, but I want to force this date cell to always have the correct date
(not necessarily the current date), and this date will be the name of the
folder (e.g. "F0607_5FEB").

Thanks in advance,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this possible , screen captures with a macro? S S Excel Worksheet Functions 0 April 11th 06 12:18 PM
How do I list a folder of "Excel file's names" to an Excel spdsht ROD Excel Discussion (Misc queries) 4 December 29th 05 12:47 AM
What formula captures specified rows of data? Brian G Scully Excel Worksheet Functions 3 November 28th 05 02:14 PM
Checking for Changes in File's Cell Layout Stratuser Excel Programming 2 May 5th 05 08:26 PM
Formula that captures criteria from 2 different columns "Help ME" poloxstar Excel Programming 1 May 26th 04 05:30 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"