#1   Report Post  
Posted to microsoft.public.excel.misc
nc
 
Posts: n/a
Default Help with macro

The following macro puts the file names on the worksheet that has the command
button. How can I put the file names on a different worksheet?




Private Sub CommandButton1_Click()

Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String

Application.ScreenUpdating = False

FileLocation = "C:\Documents and Settings\nc1\Desktop\TAS forms\*.xls"
FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Help with macro

One way:

Option Explicit
Private Sub CommandButton1_Click()

Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String
Dim newWks As Worksheet

Set newWks = Worksheets.Add
Application.ScreenUpdating = False

FileLocation = "C:\Documents and Settings\nc1\Desktop\TAS forms\*.xls"
FileLocation = "C:\my documents\excel\*.xls"
FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
newWks.Cells(ThisRow, 1) = FN
FN = Dir
Loop

End Sub


nc wrote:

The following macro puts the file names on the worksheet that has the command
button. How can I put the file names on a different worksheet?

Private Sub CommandButton1_Click()

Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String

Application.ScreenUpdating = False

FileLocation = "C:\Documents and Settings\nc1\Desktop\TAS forms\*.xls"
FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop

End Sub


--

Dave Peterson
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
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


All times are GMT +1. The time now is 06:24 AM.

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"