I have been deleting some VBComponents by using the .remove command and they get tagged for deletion but do not actually get deleted until after my VBA sub ends and control is returned to excel.
I would like to save the changes before control is returned to the user. I'm not really sure why the deletion is being held up until execution ends, it even waits until all calling functions have also finished their execution.
How would the attached file code be ammended to remove a blank row and then move all remaining rows below up one ?
Example: Open the attached file (Transport Log version 1). If you double-click in cell "X10" (for patient Abe Lincoln), the data for row 10 will be removed and written to Sheet #2. Closing the file and reopening, row 10 is empty with other rows below remaining. The goal is to move the data in rows 11 and 12 (and any subsequent rows that may be entered below those) up one row.
The above method would be an indication to users making subsequent entries to always use the first empty row below all existing data.
I have a function (courtesy of Walkanbach) to create a userform, very useful as it means I keep memory down as I can create the UF's as I go and tweak to suit.
I have been trying to get the userform to be removed when the user closes it. The close action in this case is the X button top right as this userform only has the userform itself and a listbox.
When I set the code for the event procedure it doesn't error, but nothing happens. The microsoft help pages seem to suggest that you can't remove a userform through vba, but I find that hard to believe. I've tried variations on the close procedure and all to no avail so far.
Dim xInt As Integer With TempForm.CodeModule xInt = .CountOfLines .InsertLines xInt + 1, "Private Sub TempForm_Terminate()" .InsertLines xInt + 2, "ThisWorkbook.VBProject.VBComponents.Remove TempForm" .InsertLines xInt + 3, "End Sub" End With
how you can remove the close 'X' on the title bar of a user form please? I have used this for a password input box but if the user selects the 'X' on the title bar then it closes the password box without them having to enter a password and allows them into the workbook.
I have an issue where users to a work book are selecting autofilter and then saving the document with rows filtered out, which I wish to prevent or at least warn them to remove the filter before allowing the save function.
The document is never 'Save As', it's always 'Save' from the toolbar icon.
They should be permitted to save the document, but only after this check has been completed and a message issued if the filter is on.
Is it possible to use a function that removes all toolbars upon opening the workbook and reinstates the same upon closing, the work book i am currently using does the following as described in the code. however the function is limited in that only toolbars stated in the code will be removed, if for instance there was an adobe toolbar, that remains on the screen. or is there a better way of going about this? On open:
Private Sub Workbook_Open() Run ("CreatePReturn") Run ("CreateProceed") With Application .CommandBars(" Formatting").Visible = False .CommandBars("Standard").Visible = False .CommandBars("Drawing").Visible = False .CommandBars("Return").Visible = False .CommandBars("Proceed").Visible = False .CommandBars("Worksheet Menu Bar").Enabled = False .CommandBars(" Chart Menu Bar").Enabled = False .DisplayFormulaBar = False .DisplayStatusBar = False End With With ActiveWindow .DisplayHeadings = False .DisplayHorizontalScrollBar = False .DisplayVerticalScrollBar = False .DisplayWorkbookTabs = False End With.................................
I keep getting this error message: Error 429: ActiveX Component Cannot Create Object
I fond a site that explained the problem: "If Microsoft Excel 97 is installed after an application created with Microsoft Visual Basic 5.0 that uses DAO is installed, Excel does not add the DAO design-time licensing key. This licensing key is required by Excel, but is not required by applications created with Visual Basic." But I can not figure out how to fix it. I changed the registry and added the licensing key, but I still got the error.
I often come across a situation where I know a given total, and I know it comes from numbers within a given list, but I do not know which particular numbers they are. The onyl way to find out is to add every single combination of all the numbers in the list. I want to know if there is any formula within Excel which would help me to do that, given that the numbers of combinations are:
Number of items in list Number of combinations 1 1 2 3 3 7 4 15 5 31 6 63 7 127 8 255 9 511 10 1023 Obviously, I would like to be able to do this for any number of items.
I have a control sheet that needs to fetch numbers from a different worksheets depending on the worksheet name that I type into a cell. So if I type "sheet1" into cell A1 then I want the formulas on the sheet to automatically change fetch the data from sheet1. Then if I type in "sheet2" for example, the formula must then look at sheet2 for example. The source sheets are all identical in layout so not bothered about the actual cell ranges. I can do this in VBA but would like to keep this simple in Excel formulas.
Itâ€™s been working perfectly up until around an hour ago. However, now when I close Excel, I get compile errors.
These compile errors seem to be because Excel is trying to access controls in the workbook after it has closed. Since the workbook is closed, VBA can no longer â€˜seeâ€™ the controls, and therefore it thows up errors.
Iâ€™m also getting a similar error on a Worksheets("DataExplorer").unprotect line, which seems to be because the worksheet isnâ€™t there after closing.
These errors only occur when I close the whole excel application using the big cross in the top right. If I just close the workbook (using the smaller cross just below the big cross in the top right of excel), it doesnâ€™t throw up these errors.
Just to clarify: all of the code runs perfectly when Excel is open. The errors are being thrown up for lines of code which run without problem until Excel is closed.
I have a small problem with a list of event codes in the form XX###, (Xs are letters, # numbers), I need to be able to find the largest numerical component in the list, and am having problems finiding a neat way of doing it.
I could do it by using the RIGHT command to get the numerical bit in a seperate column, then convert it to number, then use LARGEST, but this seems somewhat cumbersome!
I am trying to create a life-cycle management sheet that is simple for the user but gives specific data.
The user would input "Date", "Machine type", "Component Set No.", and "Component". This would happen over a period of time and build up a picture of how often each component was lasting and it's average life in days.
I am fine from the user input side but am struggling to figure out how to extract ONLY the data I need to display in a graph.
For example: If I want to see the average no. of days "component X" is lasting before being replaced I've not been able to extract just that data. I have tried using a pivot chart but this won't do exactly what I'm after.
See the attached for a clear explanation : Component LifeCycle Example.xlsx
VBScript code snippet below is being used in an ASP page but the call to GetObject never attaches to a running instance of Excel. Since visible property is set to True, I can see the instances accumulate in the TaskBar each time the ASP page is called, so there are obviously instances to attach to.
Dim excelApp Set excelApp = Server.GetObject(,"Excel.Application") If (err <> 0) Then Set excelApp = Server.CreateObject("Excel.Application") End If excelApp.UserControl = True excelApp.Visible = True excelApp = Nothing
GetObject errors out with the following error: Error - Number:429 Source:Microsoft VBScript runtime error Description:ActiveX component can't create object
I have a very large inventory spreadsheet (30,000+ lines) where finished goods are listed on one line and the raw materials (parts) that make up that finished good are listed below. After the last raw material for a finished good is listed, the next finished good is on the next line (and so on). First, I need to sort the lines to eliminate certain common raw materials. Next I need to take the lowest raw material inventory level and have that as the default inventory level for the finished good.
I am trying to compare multiple column in a worksheet to find common component in all the columns and what is unique to a particular column only. And list the results/finding in adj column. What i am trying to accomplish is something as below.
I have some VBA code that in one portion of it an Outlook e-mail is created and the active workbook is attached and sent. This code used to work on Excel & Outlook 2003, but now in Excel & Outlook 2007 I'm getting the error:
I need to know the command to close a workbook. I have used the information found here: http://www.ozgrid.com/VBA/userform-close.htm to disable closing the workbook via the upper right "X", but I need a button that, when clicked, simply closes the workbook instead.
I have two lists of components, a component from List A is added to one from List B and a total in £'s needs to be shown, simple enough I hear you say HOWEVER the LENGTH of component B is variable.
Input part # ABC in A1 and £50 is shown as a total in D1, then input part # 123 in B1 and the length of 100 in C1 and the total changes to £100. Then if you change the figure to 200 the total changes to £150
I have found a very useful UDF for removing non-alpha characters from strings. (See below, Credit for posting to Stanley D Grom - Ozgrid post ´Removing Non-alpha Characters From Text´).
Private Function RemoveCharacters(InString As String) As String Dim intLoopCounter As Integer Dim intStringLength As Integer Dim intASCIIVal As Integer intStringLength = Len(InString) InString = LCase(InString) For intLoopCounter = 1 To intStringLength intASCIIVal = Asc(Mid(InString, intLoopCounter, 1)) If intASCIIVal >= 97 And intASCIIVal <= 122 Then RemoveCharacters = RemoveCharacters + Mid(InString, intLoopCounter, 1) End If Next intLoopCounter End Function
1. Could the UDF be modified such that any part of a string contained within brackets is also removed (e.g. "NLGA High Street (West-Enfield), EN6" becomes "nlgahighstreeten")?
2. Can an argument be added to the format of the UDF, such that numbers (0 to 9) are either included or excluded (e.g. RemoveCharacters(A1,1) where the argument ´1´ would include any numbers (0 to 9), so "NLGA2003 High Street (West-Enfield), EN6" becomes "nlga2003highstreeten6")? ´blank´or ´0´would exclude these numbers, i.e. would return "nlgahighstreeten"