![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
Hi.
I want this macro I have written to close the workbooks it has just opened.. Sub OpenFiles() With Application .Calculation = xlCalculationManual .StatusBar = "Updating Values..." End With SData = Workbooks("RHOD1.xls").Sheets("FILES").Range("C2:C13").Value For x = 1 To 12 If SData(x, 1) <> "" Then Workbooks.Open SData(x, 1) End If Next x Calculate ' HERE NEED CODE TO CLOSE THE WORKBOOKS I JUST OPENED End Sub (There may be a better way of doing all this, I'm opening the files to update the links in my spreadsheet, then I want them closed and set calc to Manual) I'm having a bad excel day guys, any help appreciated ! RET79 |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 363
|
To save the workbook you've opened without saving do:
ActiveWindow.Close savechanges:=False
__________________
It's never too late to learn something new. Ricky |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
Ricky,
It was not quite what I was after but it certainly gave me some ideas and I have got it to work now, here is the macro just in case someone will find this useful someday: Sub OpenFiles() Dim filedata(1 To 12) a=1 With Application .Calculation = xlCalculationManual .StatusBar = "Updating Values..." End With SData = Workbooks("RHOD1.xls").Sheets("FILES").Range("C2:C13").Value For x = 1 To 12 If SData(x, 1) <> "" Then Workbooks.Open SData(x, 1) filedata(a) = ActiveWorkbook.Name a = a + 1 End If Next x Workbooks("RHOD1.xls").Activate Calculate For x = 1 To a - 1 Workbooks(filedata(x)).Close False Next x End Sub [ This Message was edited by: RET79 on 2002-05-18 15:17 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|