dir

  1. M

    Formula required to clean simple formatting errors

    I have a long list in column A in excel. I am seeking for formula to clear below formatting errors: Remove Extra space or spaces appearing before text starts in a cell Remove Extra space or spaces appearing after text starts in a cell Remove comma if appearing at the end of text in a cell...
  2. J

    Dir Do Until Loop not working

    Hi guys! I have this for loop iterating through each folder in a file path, then it goes into the folder and gets the names of the files. Only problem is that while it should be getting the name of every file in each folder, it only gets the name of the first file. So I though a Do Until loop...
  3. R

    Need help with VBA code. Many thanks in advance!

    This is a modified script from this forum and it serves it purpose well. But I the issue I am having now is that currently the script copies a bunch of values from a DIR and paste it in the main worksheet. But in this the DIR the tab names of the sheet varies so the code breaks when it...
  4. K

    VBA to find file from Hyperlink

    I am new to MrExcel and would appreciate anyone 's suggestion regarding an issue I am having with Excel VBA I have an Excel concatenated text, which I turn into a hyperlink. I am trying to loop through the list and determine which ones have a file associated and which do not: The code below...
  5. B

    Modify this VBA to List all Folders, Subfolders and Files in a Directory?

    This bit of hobbled together VBA from various sources lists all files in the selected directory. They are sorted alphabetically, then enumerated in Column 1, which is also a hyperlink to the folder the file is in. Column 2 is the filename, which is a hyperlink to the actual file. Works great for...
  6. B

    Run DIR CMD From Macro

    The command dir /S /B /A:-S > FileList.xls lists every folder, subfolder and file except for system files on a worksheet. I want the user to be able to select a folder, and obtain this result without having to run a command prompt. Is there a way to run this command from VBA? Thanks.
  7. T

    Trouble with Dir()

    Hello everyone, I am having trouble with the Dir function. This is the first time I have used it, and I don't think I understand where it searches. When I type: Dim Path As String Path = Application.ActiveWorkbook.Path MsgBox Path The Messagebox returns a path. However adding Dir: Dim...
  8. M

    "DIR" Command not working

    Using Office 365 Excel I enter into Immediate BoxDir ("E:") and I get back "180601 Temp RIBBON CALLS.BAS" which isn't even a file in E:. I add Dir ("E:*.*)"and I get bck the same thing. If I useDir("E:*.Bat") Nothing shows but there is one "*.Bat" file in the directory. Any idea of what's...
  9. T

    Looping through a folder

    I want to loop through the files in a folder, select only one that is NOT Thisworkbook, do something, then exit the loop. Dim SelectedFile As String SelectedFile = Dir(PathName:="C:\MyFolder\") Do Until SelectedFile <> ThisWorkbook.Name If SelectedFile <>...
  10. M

    VBA - Dir function not working

    Hi there, This is driving me nuts! In my current workbook I have a number of references to another workbook. In the Auto_Open sub, I want to check that the filepath for that external doc is still valid, and return an info message if not so the user can update the links if necessary. As I...
  11. J

    If period "." located in string, return "File", else return "DIR"

    Dear all, I have been tasked with reviewing network directories and files to etsablish when the directories and files were last accessed. This being in an effort to remove redundant directories and data that is no longer being used. I have used the command line to extract the required data...
  12. B

    VBA .Getdetailsof

    Hey guys, :) I currently have two related problems when running a macro, hopefully someone that is more experienced than me can figure this out: Purpose of the macro: read all files within a folder (and subfolders), list various file attributes ofeach file (file size, author etc.) on a...
  13. I

    VBA - List all Files in Folder - Dir() stops part-way through

    Hey I've got emails in a desktop folder and I'm trying to list their file names in a worksheet. I've written the below code for that purpose but I'm facing a couple of problems: 1. The filenames are truncated: 20080607-MySpace pa#BFD0E4.html appears rather than 20080607-MySpace password...
  14. K

    Problem with Dir "Invalid call or argument" after getting new computer (moving from Windows 7 to 10)

    I wanted to separate this issue from my other post that also contained a second issue that was resolved. This code snippet worked fine in 7 but fails after upgrade to 10. I get "runtime error '5': Invalid call or argument" on fname = Dir: oldpath = "\\DSGAIN01\Commercial_Printing\Work...
  15. kelly mort

    LoadPicture Controls Challenge

    Hello All, I need help to figure out what I am doing wrongly here: I wanna load image control on my worksheet with this script but I think i am doing something wrongly since I can't get the result. Sub ShowPic () Dim fPath As String, sFile As String On Error resume next fPath =...
  16. L

    VBA loop through computer folder using DIR works but fails to open files (or loop won't work without dir)

    Code: Sub DirectoryLoop MyPath = "c:\*sales*.xls*" ' Set the path. MyName = Dir(MyPath) ' Retrieve the first entry. Do While MyName <> "" ' Start the loop. MsgBox (MyName) Call ProcessFile(MyName) 'This processes each file MyName = Dir() ' Get next entry. Loop End Sub Sub...
  17. W

    How can this be done?

    Hi, I am exporting from a database to an excel file, and will need to clean up some fields in the excel file before I can upload that data to a different database. in one particular cell on the exported file, where I have listed the names and emails of the company contacts, there is a value...
  18. K

    dir limitation?

    I'm using dir to find files using wildcards and specific text in the file name. The text string is a date in yyyymmdd format. The folder being searched contains thousands of files, and when I search for a recent date "20170809" it finds the file as expected. The files in this folder go all the...
  19. M

    dir function to crawl folders and list files

    I have code to list the content of one directory's files but need to list the files in multiple directories that are listed in row one of my spreadsheet (ex: m1, m2, m3) where m1, m2, m3 are folders. I cannot get the dir function to use a variable in my loop to pull the text of m1, m2, m3 in...
  20. R

    Object required error

    Dim fso As Object Dim dir As Object Dim file As Object Dim rangews As Worksheet Dim fPath As String fPath = "censored" Set rangews = ThisWorkbook.Worksheets("Sheet1") Set fso = CreateObject("Scripting.FileSystemObject") Set dir = fso.GetExtensionName(fPath) line set dir =.... gives me...

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top