+ Reply to Thread
Results 1 to 3 of 3

Need File Name from a particular assigned folder path.

Hybrid View

  1. #1
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Need File Name from a particular assigned folder path.

    Hi Everyone,

    I am at initial stage of learning VBA Macro

    I need small help to get file names from a particular assigned folder and i tried below coding its not working and i am unable to understand why its not working.

    Sub get_filename()
    Dim fdr As String
    mrow = 8
    macro_sheet = ActiveWorkbook.Name
    spath = Range("B2").Value
    fdr = Dir(spath & "\" & "*.*")
    Do While fdr <> ""
    'Debug.Print fdr
    Cells(mrow, 5).Select
    fdr = Dir
    mrow = mrow + 1
    Loop
    End Sub
    can anyone please help me in this and i need this steps for cumulating purpose.

    Thanks in Advance !
    MNR.

    Moderator's note: Don't forget to put code tags around your codes. thanks.
    Last edited by vlady; 11-07-2012 at 03:05 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Need File Name from a particular assigned folder path.

    put in B2 the folder to be scanned tlike C:\test, the change line Cells(mrow, 5).Select to Cells(mrow, 5).Value = fdr
    If solved remember to mark Thread as solved

  3. #3
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Thumbs up Re: Need File Name from a particular assigned folder path.

    Thanks alot sir,

    its working very nicely ur correct instead of mention cells(mrow,5).select and i used ur code cells(mrow,5).value = fdr.

    Once again thanks & today i learn new thing here.

    one more thing sir how to make this thread got solved.

    Thanks,
    Naveed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1