I hate to have to come back to the forum after I Thanked you all for solving my problem, but here I am.
The code below disables the (X) button, no problems
Option Explicit Public BooleanForClosing As Boolean Private Sub Workbook_BeforeClose(Cancel As Boolean) If BooleanForClosing = False Then Cancel = True MsgBox "Please Use Exit Button" End If End Sub
The next code saves the workbook , but won't Quit the programme and goes back to the Exit Button ...
In my spreadsheet, a series of macros calls an external program/application three times.
Each time the program finishes, it (and not Excel, as I formerly thought) opens a resource (*.res) file in Notepad, which of course goes into the taskbar. Since I need to run the spreadsheet seven or eight times in a row, the taskbar can get cluttered quickly.
The program opens three different instances of the same filename: iroutine.res.
Is there a way to get Excel to close these Notepad files (if it's simpler to do, it can kill all instances of Notepad) when it finishes running its routines?
At the moment, there is no compile error or runtime error, but if I manually attempt to open the file (that was successfully read from), I get the message that the file is already open and is locked by myself (the user) and that multiple Excel processes are still running (I checked the task manager).
How do I close this Excel file (no changes to be made since I only read from the file) and quit Excel from running ?
Here is what I have at the moment :
Dim FirstName, Surname As String 'file path and name for the Excel file Dim FileNamePath As String = "C:UsersMRCDesktopMRC FilesVisual Basic FilesSwimManager 2014CurrentSeasonDATASquadData.xls"
I was wondering if there is any code using an on-click method. When clicking a button i need excel to exit the file/sheet without saving (no prompts) and then re-open the exact same file/sheet once it has closed.
I want to delete some unwanted rows on closing my excel file. the blank rows are between set of datas. so it has to check all the blank rows, delete it until the last one. example
data blank rows data blank rows data blank rows data
I have a userform which opens when the workbook opens. Ideally Id like to have the userform open without the workbook coming up and have the workbook close when you close the userform. If thats not doable then is there a way to just close the workbook when the userform is closed?
I was asked to create a userform for the use of our whole team which would enable them to select a name from a dropdown list and then it would display their business contact details in the rest of the form.
I'm running Office 2010 and Windows XP server/enterprise edition (not quite sure which). After some research I've managed to use VBA code to open the userform while hiding the workbook, then when the close button is clicked it closes the user form and it's associated workbook using the code below.
Code: ' ThisWorkbook module Private Sub Workbook_Open() Application.Visible = False UserForm1.Show End Sub 'UserForm module Private Sub CommandButton1_Click() Unload UserForm1 ThisWorkbook.Close (False) End Sub
This works great when the excel file is accessed directly. However when the excel file is accessed via the link on my teams Sharepoint site it doesn't. When the Userform is closed the underlying workbook and data is then displayed which then has to be closed separately.
I'm trying to use Application.FileSearch in a procedure to open files in a folder one by one and then do some stuff. It works fine when I developed it on my Windows machine but won't work on the Mac platform. The culprit instruction seems to be the
Application.FileSearch instruction, and I've also tried what I think may be a Mac equivalent Application.FileFind, but I get the 'Object doesn't support this action' error.
So I wrote a simple procedure below just to test the .FileSearch instruction but this fails in the same way.
Any ideas anyone? I've commented out lines which relate to Windows syntax.
I have some code that I am using to save and close the active workbook, this code works perfectly, but I need the code to also close the excel application, not just the workbook. I have tried active window.close but it didn't work even though when I recorded the actions that was the code that I was give.
background -I set a task in my OS to open the workbook, then I wrote some code on the Workbook.open trigger to run and then save and close, but only the activebook closes.
Excel will hang up as if it's gone into a continuous loop (Although no looping macros are active) when you open or close a user form. The task bar in Excel will flash Ready Calculate. Visual basic reports no code is running but excel either crashes or becomes very unresponsive. I have to exit and reopen excel in order to fix the problem . It also doesn't happen at any one specific point it can vary. I have various VLOOKUPs around the workbook and userforms display the correct information. I use the INDEX formula in the control source of textboxes. I also use the offset formula to make sure DTPICKER displays correctly.
I am using 'Option Explicit' at the start of all my code. I have tried a 3rd party code cleaner. No visual Basic references are MISSING
I encountered a strange anomaly where a worksheet "freezes" when Application.DisplayFormulaBar = False. I can only replicate this in Excel 2013. Excel 2010, for example, works perfectly well, and as expected.
[Code].....
To replicate the anomaly (Excel 2013 only):
1. In a new workbook, insert an ActiveX command button on "Sheet1", no code required.
2. Run the following code
[Code] .....
3. Click on the command button.
4. Now click on any cell and try to enter a value.
Is your screen "frozen"? If so, go to another sheet, return to Sheet1 and try again. Does it work?
Here's an alternative code for MyTest() that causes no problems. Can spot the difference? Is there a reasonable explanation?
[Code] ....
Even more curious, call the following MyTest3 on Workbook_Open() and the workbook behaves. Run MyTest3 again and the screen starts freezing(!)
I have a piece of code that was written by someone else (namely Phil_V, from these very forums) that only works in versions of Excel before 2007. I was just hoping that someone could update the code for me?
I know it's a lot to ask, but I simply don't have the expertise to do it myself I really appreciate any help received.
I wrote a macro to list all the excel files from a directory and its sub-directories to an excel sheet. It is working in excel 2003 but shows error (object does not support this action) in 2007. Actually I have copied almost this entire macro from excel 2007 help only. Can somebody modify this to use in both the versions of excel?
If input is entered into column C (range C2:C100), then row cells for columns D, E ,F, H or I must NOT be blank upon save. Could be that one or more of these row cells are left blank by mistake.
An error msg pops up upon attempting to save, stops the save and colors each cell yellow that needs info entered into.
Someone Im working with says she used to change Excel to work on it on some vertical monitor. Is there a way to do that in Excel 2010 or even 2007?
Obviously I'm not talking about print layout, but viewing the whole application in portrait view, as if she turned a monitor sideways and altered the Aps view.
How I can directly write info from an external application to an Excel sheet
Actually, I'm using a special dll collection to do it, but I would need to buy the 64 version soon. Problem is I use only one function of the entire collection so I want to look on how to create it my self. Basically, it took data from my charting software and write directly to my Excel Worksheet.Cell
I need to resize Excel pretty frequently - I need to size the whole Excel app tall and all the way to the left, taking up about a third of my screen - then maximize it - then back to tall and left, etc. I can do it by clicking the "Restore Down" icon in the top right corner, but I can't figure out how to do it using the keyboard.
I've tried Ctrl-F8, Ctrl-F9 and Ctrl-F10, but they all act on individual workbooks within the Excel application. I want to resize the whole Excel application. Does it exist?
I have the following code which edits an excel file and saves it in a different format, I think want the code to take this newly saved file and open it in an external application (Softplot) and then save it through this new application.
VB: Sub FormatMacro1a(ws As Worksheet) ws.Copy Rows(1).Delete Columns("D:E").Cut Destination:=Columns("J:K") Columns("F:K").Cut Destination:=Columns("D:I") Range("E1:E201").Value = "0"
[Code] .....
As it stands I have the file saving in a new format and I can open a specific file in softplot through VBA however where I am getting stuck is opening my newly saved file and then saving it.
I am using Windows 7 and have a piece of code that brings up a warning message after 20 minutes to warn the user they have been in a workbook for too long.
If they have the Excel application window minimized, is there a way to get Excel to take the application out of minimized mode into max screen, before revealing the message.
Currently when the warning message activates, the excel icon just flashes in the start bar. Some users may not see this.
Here is the code I have so far:
[Code] ....
I have already tried simply adding a piece of code with maximize screen, however this doesn't seem to work.
I was wondering if it is possible to have cells formatted based on the presence of an autofilter? I have a large worksheet, and to clean it up I would like to make the entire sheet (minus the category headers) invisible. Then, when the user applies a filter, the cells become visible.