Update Code - From simply Closing the files to Saveas. (Same Location, Name and Ext)

epoiezam

New Member
Joined
Jan 28, 2016
Messages
36
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys, I'm back :)

Need some assistance here. With the said code below. How can we "SAVEAS" the file/s instead of just "CLOSE"ing it.
Just want to close the file properly so that none of those unclose workbook file still hanging around.


Dim i As Long, objFolder As Object, wsFiles As Worksheet
Dim colFiles As Collection, arrFiles, WB, MyPath As String


MyPath = "H:\0.0.1 LEAD REFERRAL\0.1MyFiles\"
'Filename = "UB Tracking"

Set colFiles = GetMatchingFiles(MyPath, "UB Tracking.xlsx")
Debug.Print "Found " & colFiles.Count & " matching files"

ReDim arrFiles(1 To colFiles.Count, 1 To 3) 'size output array

Application.ScreenUpdating = False

For i = 1 To colFiles.Count
Set WB = Workbooks.Open(colFiles(i), ReadOnly:=True)
arrFiles(i, 1) = WB.Path
arrFiles(i, 2) = WB.Name
arrFiles(i, 3) = WB.Sheets(1).UsedRange.Rows.Count - 1
=> WB.Close False '<= Save the file in the same loc, name and ext.


Next i
Application.ScreenUpdating = True
Set wsFiles = ThisWorkbook.Sheets("Sheet1")
wsFiles.Range("F2").Resize(colFiles.Count, 3).Value = arrFiles
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Guys,

Nevermind, manage to find away to solve it..

Thanks
 
Upvote 0
Good to hear you have found a solution.

If you would like to post that solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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
Back
Top