macro to open files refresh all save close

kingcc

New Member
Joined
Oct 9, 2017
Messages
11
i am trying to use 3 stable databases store in a folder and use them to several workbooks

first questions is how to link formulas to external database?
i found some wizards for queries but i didn't understood them

i write formulas like that
VLOOKUP(A14;'Z:\data\[UV_C_ItemListMarkup.xls]Sheet'!A$1:C$65536;3;FALSE)

and seems works good but i have problems in refresh of the databases
so i thought that if i had a macro to active workbook and open the databases refresh them save and close it would be a good trick

i read some posts but didn't worked as i would like


https://www.mrexcel.com/forum/excel-questions/461823-macro-open-refresh-all-save-close.html

my databases are stored in z:\data
UV_C_ItemListMarkup.xls
UV_ItemCriteria.xls
ΕΥΘΥΒΟΥΛΗΣ.xlsx

so it's 2 xlx and 1 xlsx

non of them have a macro in
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
in the moment i found that code
it seems good

Sub LoopThroughFiles()
Dim strFile As String, strFolder As String
Dim wb As Workbook

strFolder = "Z:\DATA"
strFile = Dir(strFolder & "*.xlsx")
Do While Len(strFile) > 0
On Error Resume Next
Set wb = Workbooks.Open(strFolder & strFile, UpdateLinks:=True)
On Error GoTo 0
If Not wb Is Nothing Then
Application.Calculate
wb.Close SaveChanges:=True
Set wb = Nothing
Else
Debug.Print "Couldn't open: " & strFolder & strFile
End If

strFile = Dir
Loop
End Sub
 
Upvote 0
Hi Kingcc,

I'm pretty new to excel, I need the macro to work you've posted above.

Can you show me which bits I need to change for my data please?

I just need one workbook to open, refresh, save and then close.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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