Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to create macro that will display the sub_subfolder

I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder contains
multiple(more than 100) number of files (.s3p format) that I want to analyze.

I want to create a macro that will allow user to input the main_folder
directory. Then, the all the subfolder will be listed up on the mainsheet, so
that user can choose which subfolder they want to analyze. (where user can
analyzed 1, 2, more or all the subfolder). Can someone help me on this?

I have tried so many ways, but it doesn't works.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default how to create macro that will display the sub_subfolder

Check out Dir() in the help.

NickHK

"cyzax7" <u22797@uwe wrote in message news:6173e848330a5@uwe...
I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder

contains
multiple(more than 100) number of files (.s3p format) that I want to

analyze.

I want to create a macro that will allow user to input the main_folder
directory. Then, the all the subfolder will be listed up on the mainsheet,

so
that user can choose which subfolder they want to analyze. (where user can
analyzed 1, 2, more or all the subfolder). Can someone help me on this?

I have tried so many ways, but it doesn't works.



  #3   Report Post  
Posted to microsoft.public.excel.programming
ADG ADG is offline
external usenet poster
 
Posts: 76
Default how to create macro that will display the sub_subfolder

Hi

Copeid below example on FileDialog from the help text in Excel, this could
be an option for you. Just replace the message box code etc

Sub UseFileDialogOpen()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub
--
Tony Green


"cyzax7" wrote:

I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder contains
multiple(more than 100) number of files (.s3p format) that I want to analyze.

I want to create a macro that will allow user to input the main_folder
directory. Then, the all the subfolder will be listed up on the mainsheet, so
that user can choose which subfolder they want to analyze. (where user can
analyzed 1, 2, more or all the subfolder). Can someone help me on this?

I have tried so many ways, but it doesn't works.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to create macro that will display the sub_subfolder

hi,

It doesn't work. I want to create the macro that display my subfolder. the
problem is, it display only the FILES (for example files of type: sample1.
ppt, sample2.txt and etc ) in the main_folder (not the sub folder that I want)



ADG wrote:
Hi

Copeid below example on FileDialog from the help text in Excel, this could
be an option for you. Just replace the message box code etc

Sub UseFileDialogOpen()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub
I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder contains

[quoted text clipped - 6 lines]

I have tried so many ways, but it doesn't works.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default how to create macro that will display the sub_subfolder

Hi Cyzax7,

Try:

'=============
Public Sub ListFolders()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Const sStartDir As String = "C\" '<<==== CHANGE

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder("C:\")
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============


---
Regards,
Norman


"cyzax7" <u22797@uwe wrote in message news:6173e848330a5@uwe...
I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder
contains
multiple(more than 100) number of files (.s3p format) that I want to
analyze.

I want to create a macro that will allow user to input the main_folder
directory. Then, the all the subfolder will be listed up on the mainsheet,
so
that user can choose which subfolder they want to analyze. (where user can
analyzed 1, 2, more or all the subfolder). Can someone help me on this?

I have tried so many ways, but it doesn't works.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default how to create macro that will display the sub_subfolder

Sub Finddir()
Dim FSO As Object
Dim fDir As Object
Dim fSubDir As Object
Dim i As Long
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fDir = FSO.GetFolder("C:\MyTest")
For Each fSubDir In fDir.SubFolders
i = i + 1
Cells(i, "A").Value = fSubDir.Name
Next fSubDir
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"cyzax7" <u22797@uwe wrote in message news:6173e848330a5@uwe...
I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder

contains
multiple(more than 100) number of files (.s3p format) that I want to

analyze.

I want to create a macro that will allow user to input the main_folder
directory. Then, the all the subfolder will be listed up on the mainsheet,

so
that user can choose which subfolder they want to analyze. (where user can
analyzed 1, 2, more or all the subfolder). Can someone help me on this?

I have tried so many ways, but it doesn't works.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default how to create macro that will display the sub_subfolder

Hi,

In the code below, the directory is set in the macro. How should I make the
macro read a user defined directory which is entered in excel.
What I mean is:

1. In the mainsheet (Excel), user will enter the directory for the
main_folder.

2.Then , once user click on the "Search" button, it will list all the
subfolder (from the main_folder directory) in the mainsheet at a specified
row and column.Let say row 4, column "C".

Norman Jones wrote:
Hi Cyzax7,

Try:

'=============
Public Sub ListFolders()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Const sStartDir As String = "C\" '<<==== CHANGE

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder("C:\")
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============

---
Regards,
Norman

I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder

[quoted text clipped - 9 lines]

I have tried so many ways, but it doesn't works.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default how to create macro that will display the sub_subfolder

Hi Cyzax,

Try
'=============
Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Dim sStartDir As String

sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============


---
Regards,
Norman



"cyzax7 via OfficeKB.com" <u22797@uwe wrote in message
news:618029ac90469@uwe...
Hi,

In the code below, the directory is set in the macro. How should I make
the
macro read a user defined directory which is entered in excel.
What I mean is:

1. In the mainsheet (Excel), user will enter the directory for the
main_folder.

2.Then , once user click on the "Search" button, it will list all the
subfolder (from the main_folder directory) in the mainsheet at a specified
row and column.Let say row 4, column "C".

Norman Jones wrote:
Hi Cyzax7,

Try:

'=============
Public Sub ListFolders()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Const sStartDir As String = "C\" '<<==== CHANGE

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder("C:\")
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============

---
Regards,
Norman

I have a main_folder (I name it as Folder_A) which contains many
subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder

[quoted text clipped - 9 lines]

I have tried so many ways, but it doesn't works.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default how to create macro that will display the sub_subfolder

Hi Norman,

I've tried the code and its work. I have created a CommandButton that will
direct to the ListFolders2.How should I modify the code so that the
CommandButton and the listed subfolder will display on the same page (let say,
in my sheet1 which I called as "Home").
I've tried to modify the code, but nothing shows up.
I'm very new to vba programming. ;(


Norman Jones wrote:
Hi Cyzax,

Try
'=============
Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Dim sStartDir As String

sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============

---
Regards,
Norman

Hi,

[quoted text clipped - 56 lines]

I have tried so many ways, but it doesn't works.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default how to create macro that will display the sub_subfolder

Hi Norman,

I've tried the code and its work. I have created a CommandButton that will
direct to the ListFolders2.How should I modify the code so that the
CommandButton and the listed subfolder will display on the same page (let say,

in my sheet1 which I called as "Home").
I've tried to modify the code, but nothing shows up.
I'm very new to vba programming. ;(


- Cyzax -

Norman Jones wrote:
Hi Cyzax,

Try
'=============
Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Dim sStartDir As String

sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============

---
Regards,
Norman

Hi,

[quoted text clipped - 56 lines]

I have tried so many ways, but it doesn't works.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default how to create macro that will display the sub_subfolder

Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Home"
Dim sStartDir As String

sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")

On Error Resume Next
Set SH = Worksheets(sName)

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

Set SH = Nothing

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Norman Jones" wrote in message
...
Hi Cyzax,

Try
'=============
Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Dim sStartDir As String

sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============


---
Regards,
Norman



"cyzax7 via OfficeKB.com" <u22797@uwe wrote in message
news:618029ac90469@uwe...
Hi,

In the code below, the directory is set in the macro. How should I make
the
macro read a user defined directory which is entered in excel.
What I mean is:

1. In the mainsheet (Excel), user will enter the directory for the
main_folder.

2.Then , once user click on the "Search" button, it will list all the
subfolder (from the main_folder directory) in the mainsheet at a

specified
row and column.Let say row 4, column "C".

Norman Jones wrote:
Hi Cyzax7,

Try:

'=============
Public Sub ListFolders()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Const sStartDir As String = "C\" '<<==== CHANGE

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True

Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder("C:\")
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

End Sub
'<<=============

---
Regards,
Norman

I have a main_folder (I name it as Folder_A) which contains many
subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder
[quoted text clipped - 9 lines]

I have tried so many ways, but it doesn't works.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1





  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default how to create macro that will display the sub_subfolder

Hi,

I' ve solved the prob...
thanxs... ;

Bob Phillips wrote:
Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Home"
Dim sStartDir As String

sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")

On Error Resume Next
Set SH = Worksheets(sName)

Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr

SH.Columns("A").AutoFit

Set SH = Nothing

End Sub

Hi Cyzax,

[quoted text clipped - 99 lines]

I have tried so many ways, but it doesn't works.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1
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
Create a macro to create excel line graph with coloured pointers anddata lables anuj datta Charts and Charting in Excel 1 September 30th 09 04:04 PM
create searchable data and display on the web Annie Excel Discussion (Misc queries) 0 March 5th 09 08:41 PM
Create from to display data from another tab JHLou Excel Discussion (Misc queries) 4 March 14th 08 08:33 PM
Can I create a display box to see results no matter where I am in jeroamd Excel Discussion (Misc queries) 3 June 27th 06 04:20 PM
how do i create a macro to clear checkboxes and display a message. Xavierskyrider Excel Programming 7 February 25th 05 09:37 PM


All times are GMT +1. The time now is 10:21 PM.

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

About Us

"It's about Microsoft Excel"