ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting file names to excel (https://www.excelbanter.com/excel-programming/394562-exporting-file-names-excel.html)

[email protected][_2_]

Exporting file names to excel
 
I would like to export file name from "Y:\ReleasedDrawings" to excel.
Can someone help me out?
Thanks
Vedat


Wigi

Exporting file names to excel
 
You could use the loop written out he

http://www.jumper.ch/english/e_014.htm


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


" wrote:

I would like to export file name from "Y:\ReleasedDrawings" to excel.
Can someone help me out?
Thanks
Vedat



JLatham

Exporting file names to excel
 
A tried and true method, not dependent on the FSO:

To get it into code to run: press [Alt]+[F11] to open the VB Editor, use the
VB editors menu to Insert | Module and copy the code below and paste it into
the code module. Close the VB editor. Choose Tools | Macro | Macros from
the main Excel menu and run the ExportFileNames macro.

Sub ExportFilenames()
Const basicPath = "Y:\ReleasedDrawings\"
'change worksheet name and
'starting cell
'as needed for your workbook
Const wsName = "Sheet1"
Const startCell = "A2"

Dim anyFilename As String
Dim anyRange As Range
Dim rOffset As Long

rOffset = Cells(Rows.Count, Range(startCell).Column).End(xlUp).Row - 1
Set anyRange = Worksheets(wsName).Range(startCell)
Worksheets(wsName).Select
Application.ScreenUpdating = False ' improves speed
anyFilename = Dir$(basicPath & "*.*", vbNormal)
Do Until anyFilename = ""
anyRange.Offset(rOffset, 0) = anyFilename
rOffset = rOffset + 1
anyFilename = Dir$()
Loop
anyRange.Select
Application.ScreenUpdating = True

End Sub


" wrote:

I would like to export file name from "Y:\ReleasedDrawings" to excel.
Can someone help me out?
Thanks
Vedat



[email protected][_2_]

Exporting file names to excel
 
On Aug 1, 11:54 am, JLatham <HelpFrom @ Jlathamsite.com.(removethis)
wrote:
A tried and true method, not dependent on the FSO:

To get it into code to run: press [Alt]+[F11] to open the VB Editor, use the
VB editors menu to Insert | Module and copy the code below and paste it into
the code module. Close the VB editor. Choose Tools | Macro | Macros from
the main Excel menu and run the ExportFileNames macro.

Sub ExportFilenames()
Const basicPath = "Y:\ReleasedDrawings\"
'change worksheet name and
'starting cell
'as needed for your workbook
Const wsName = "Sheet1"
Const startCell = "A2"

Dim anyFilename As String
Dim anyRange As Range
Dim rOffset As Long

rOffset = Cells(Rows.Count, Range(startCell).Column).End(xlUp).Row - 1
Set anyRange = Worksheets(wsName).Range(startCell)
Worksheets(wsName).Select
Application.ScreenUpdating = False ' improves speed
anyFilename = Dir$(basicPath & "*.*", vbNormal)
Do Until anyFilename = ""
anyRange.Offset(rOffset, 0) = anyFilename
rOffset = rOffset + 1
anyFilename = Dir$()
Loop
anyRange.Select
Application.ScreenUpdating = True

End Sub



" wrote:
I would like to export file name from "Y:\ReleasedDrawings" to excel.
Can someone help me out?
Thanks
Vedat- Hide quoted text -


- Show quoted text -


Thank you. This is perfect.



All times are GMT +1. The time now is 10:53 AM.

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