dir function

  1. S

    If Dir(FullName) <> vbNull String Then Giving Runtime Error 52

    Howdy! This VBA code has been running strong for a year, then all of a sudden I got a call today that it's started giving an error, and I'm really not sure what to do to fix it, as I essentially backwards engineered some other code to get this to work and I have no actual clue what I'm doing...
  2. V

    Dir function does nothing

    Hello, I have a problem on the dir function, as i run the code, it does nothing. I want to prompt a message asking to overwrite file if the file already exists in the directory. Thanks before. Sub SavePDF_Cost() Dim DocPath As String Dim DefName As String Dim EmpID As String...
  3. A

    Workaround DIR() limitation

    Ok so I am running into a problem with using the below code since I started storing it on OneDrive. Basically, what the code is supposed to do is copy the existing worksheet to a new workbook and then save the workbook; prior to this though it is supposed to delete any previous/existing version...
  4. C

    VBA to open up folders on drive

    I looked around a bit and I haven't really been able to find what I'm looking for. Is there a way to have VBA loop through files on a drive to retrieve other excel workbooks? But, without having to use the file picker? I have over 100 file folders I need to go into. And I have multiple files...
  5. J

    Network oddity?

    Not sure if this is a problem with my code, with Win8, with our network, or something else, but I'm having some trouble with the Dir function. Specifically, I'm using the Dir function to try and pull file names from the folder, and the end result is that I can navigate to the folder, but when I...
  6. ChrisUK

    Rename files

    Hi, I have written the following code to run through the files in a named folder and identify any charactors in a second sheet and then replace with a given replacement. This works perfectly well except it doesn't go through any sub folders it finds, which is a little annoying Any one...
  7. S

    Fast file search for most recently modified file

    Greetings, I recently threw together a bit of code that parses text from the most recently modified file in a selected folder. However, the folder keeps track of job tickets at my work, and it can fill up fairly quickly. Right now, 889 .txt files are in the folder to be searched. I have...
  8. L

    VBA Finding file in directory with LARGEST file size.

    Hiya all, I've got everything working for this Macro except for one piece to this puzzle. I'm in the process of trying create an Email Attachment system that loads the "Signature" from Outlook. Our company uses multiple signatures for various types of emails (Default email Sig, Vendor sig...
  9. J

    Pull files from folder

    I'm trying to sort through and import a number of bar-delimited text files into an Excel spreadsheet, and running into trouble with the Dir function. My code follows: Option Explicit Dim wbMonthly, wbYTD As Workbook Dim strFileName, strType, strPrd, strFile As String Dim lngBlank As Long...
  10. E

    Using Dir(ActiveWorkbook.FullName) Causes Macro to Stop Working

    Hey all, I've inherited a macro that I'm trying to modify to capture additional info. Currently, the macro extracts data from all spreadsheets in a folder (that meet certain conditions). However, when I add in the commands to grab the filename, it causes the macro to only successfully loop...
  11. P

    Help! Excel VBA "Dir" statement converting ≤ and ≥ to = !!!

    Hi all, Am well and truly stumped by this one... I'm writing a file backup utility which depends on reading the contents of a bunch of folders and working out which files to copy to a backup location. Trouble is, a couple of files have "greater than / equal to" and "less than / equal to"...
  12. B

    DIR function doesn't iterate

    Hi all, When I step-through my code below, it always opens the first file in the directory "C:\Pyramid Files", but when it comes back to the Pyramid Files sub after fully processing the first file via various other subs, the VB Editor apparently doesn't like something about this line: StrFile =...
  13. M

    Find files in subdirectory of a subdirectory

    I used code from Microsoft Support (Method 2) to search through subdirectories and find a specific file. It works if I make the path specific enough so that my file is in the subdirectory of that path. However, I would like to generalize my search a bit more and name my path as a folder that is...
  14. L

    Dir Function problem

    Hi, I'm currently taking my first steps into using VBA to manipulate files, and have hit a stumbling block with the Dir function. The code below is a what I'm playing with, Sub ffile() ActiveCell = fileExists("fname") End Sub Function fileExists(fname) As String fileExists = Dir(fname) End...

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back