i need a macro
i will place the macro in any file and i will run that macro
and when i run that macro all files should be closed if there will be any opened file except the file in which macro is placed
i need a macro
i will place the macro in any file and i will run that macro
and when i run that macro all files should be closed if there will be any opened file except the file in which macro is placed
Last edited by DocAElstein; 06-24-2020 at 03:07 AM.
Put this macro http://www.excelfox.com/forum/showth...ll=1#post12537 in any file.
Run the macro
All Excel files will be closed , except the file in which you have put the macro: The file with the macro will stay open. All other Excel files will be closed.
Last edited by DocAElstein; 03-03-2020 at 05:14 PM.
….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
If you are my enemy, we will try to kick the fucking shit out of you…..
Winston Churchill, 1939
Save your Forum..._
_...KILL A MODERATOR!!
problem solved code works perfect no doubt in itCode:Sub STEP1() Dim AnyWb As Workbook For Each AnyWb In Workbooks If AnyWb.Name <> "Book1.xlsm" Then AnyWb.Close Savechanges = False Else End If Next AnyWb End Sub
But i have one question i just downloaded the file and by default it is in a opened state & after that i open vba macro placed file and when i run the code its not working
but i download the file if file is opened and i close that file and again i open that file and then i open the vba placed file and ran the macro then code works
Any idea about this problem
is this problem solvable bcoz i already have the code to close the file but u r a profession vba programmer so i thought if u provide me the code then problem can be solved
Sorry, I do not understand what you are saying. I do not think anyone can understand what you are saying.
I think maybe you need to find somebody that can speak your language, and also the English language.
I think you need to find a translator to help you ask your questions.
I try now to geuss your question...
Is this your question?
Question Suggestion 1
I may have some Excel files open. ( We will call them the “already_opened” Files )
These I want to stay open.
I may then open some other Excel files. They may be any type of excel file . I want a macro that will close all these files that were opened. But I want the already_opened files to stay opened.
_._______________________________
I can answer Question Suggestion 1 if you wish?
Last edited by DocAElstein; 03-03-2020 at 05:57 PM.
….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
If you are my enemy, we will try to kick the fucking shit out of you…..
Winston Churchill, 1939
Save your Forum..._
_...KILL A MODERATOR!!
Leave this topic it is solved No doubt Thnx Doc Sir for the Support and guidance i will manage that problem
Moderator notice
Problem is possibly related to this cross post
https://chandoo.org/forum/threads/vba-macro.44302/
An issue with possibly a file not in the current instance of Excel .....
and another go in July, 2020
https://www.mrexcel.com/board/thread...macro.1140953/
https://www.eileenslounge.com/viewto...p?f=30&t=35046
https://www.excelforum.com/excel-pro...ml#post5369738
Last edited by DocAElstein; 07-28-2020 at 01:54 PM.
vba is placed in a seperate file 1.xlsm
now what i need
there can be 2-3 or it can be 4 files opened along with this 1.xlsm
i will be in 1.xlsm file & i will ran the macro
now what i need is when i ran the macro it should go to next open file and use ALT+ F4(this is shorcut key to close the excel file) and that will be close and then again go to next open file and use ALT+ F4 and again if there is a file then do the same do till all files are closed except 1.xlsm
and i wanted to inform u sir by doing ALT+ F4 only my file is closing and i want to close all the file by this way only sir
So plz have a look into this problem and help me in solving this problem
we have to solve this problem only by vba only sir so plz help sir & mam
Try this
Code:Sub CloseAllOtherWorkbooks() ' ' CloseAllOtherWorkbooks Macro ' Keep this workbook open and close all other workbooks in this instance ' ' Keyboard Shortcut: Ctrl+q ' Dim wbk As Workbook Dim strBookNames() As String Dim lngBooksCount As Long For Each wbk In Application.Workbooks If wbk.Name <> ThisWorkbook.Name Then lngBooksCount = lngBooksCount + 1 ReDim Preserve strBookNames(1 To lngBooksCount) strBookNames(lngBooksCount) = wbk.Name End If Next wbk For lngBooksCount = 1 To lngBooksCount 'Change to True if the files have to be saved before closing Workbooks(strBookNames(lngBooksCount)).Close False Next lngBooksCount Set wbk = Nothing Erase strBookNames End Sub
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
Thnx ExcelFox for helping me in solving this problem
Actually i downloaded the file and i open the macro file and i ran it but its not working i tried many code to close the file but its not closing
when i close the file and then i open then it is closing the code is perfect no doubt
i learned that once i download the file and it opens by default then macro will not work until its close and reopen again
i searched on google there was alt+F4 which is closing that file but i think if we use that also in the vba code then it will also not work i will manage it
Not sure I understand that. So you're saying the code I sent works, right?
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
Assuming this is closed here
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
Bookmarks