I have a module in Access to format cells in an Excel spreadsheet.
Sub FormatData()
Workbooks.Open FileName:="C:\Users\john.doe\Documents\scripts\apps\allow\Weekly_Cash_Trending"
Workbooks("Weekly_Cash_Trending.xlsx").Activate
Columns("C:C").Select
Selection.NumberFormat =...
the tmp = Dir will repeat for that specific file, and return an empty string when all files are renamed, which is your exit condition - the code loops correctly. For all file in the specified folder. :-)
This was resolved by removing the If Len(Dir(...)) condition. Using Dir inside the loop breaks the Dir outside the loop.
Corrected code below.
Function process()
'
Dim tmp As String
tmp = Dir("C:\Users\Calhoun\Documents\REPORTING\Correspondence\*.txt")
Do While tmp > ""
on error...
I am very new to VBA, so please be patient. I need to to re-name .txt files in a folder to a file name that never changes (it is linked as a table in Access). Run a macro that scrapes data into another table, then repeat the process for all the files in the folder (loop). The code below renames...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.