Bug - Macro Crashes When Run, Doesn't Crash If Save First
I'm just wondering if any of you can lend some help on a bug i'm encountering. When I press a button on my worksheet to call a macro that brings up a userform, the excel will crash, and give that "do you want to report this error", close down excel, and reopen on a blank worksheet. Strange thing is, this error is avoided if I save the workbook upon opening it, and then call that macro.
The workbook does not read data from external sources, so i dont think is that problem.
Has anyone encountered this?
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Combo Box Macro In Worksheet Doesn't Run Automatically
I have a combo box in a worksheet with a macro written for it that works fine but when I open the worksheet it doesn't run automatically, I have to find the macro and tell it to run. How can I get it to run as soon as the worksheet is opened Here is the code for the macro Private Sub combobox() ComboBox1.clear ComboBox1.AddItem "Mit Rekuperator" ComboBox1.AddItem "Ohne Rekuperator" End Sub Private Sub ComboBox1_Change() Run "PinchInternHeatExchanger" Select Case ComboBox1.Text Case "Mit Rekuperator" ActiveSheet.Range("I62") = Worksheets("uorc").Range("L99") Case "Ohne Rekuperator" ActiveSheet.Range("I62") = Worksheets("uorc").Range("E11") End Select Run "PinchPoint" End Sub
View Replies!
View Related
Workbook_Open Doesn't Run On Second Open
I have noticed this on more than one workbook with an Workbook_Open macro. When you open Excel, open Workbook1, do some work , save or don't save and close, then reOpen Workbook1 without having closed the Excel application, the Workbook_Open macro in Workbook1 doesn't run. Closing Excel and reopening Workbook1 initiates the Workbook_Open macro. It's as if Excel remembers having previously opened Workbook1 and so it doesn't rerun the Workbook_Open macro the next time you open it.
View Replies!
View Related
Save Workbook To Desktop If File Doesn't Exists
I'm having a slight problem with this script. What I'm looking to do is before the workbook is closed is check to see if the workbook already exisits on the users desktop if it doesnt then save it to the users desktop. if is does exists then just exit the sub. Here is what I have so far but for some reason it kept displaying the aleart message that the file already exists and wants to save it again. I just added the displayalerts = false in but the script still does not know that file already exists. So when the file is closed it keeps saying file has been placed on your desktop.
View Replies!
View Related
FileSearch Method In 2007, Run-time Error 445 Object Doesn't Support This Action
I was using the following macro on Excel 2000, 2002 & 2003 for many years without a fuss. Recently, I upgraded to Excel 2007. When I run the macro now, I get the following error message:- Run-time error 445 Object doesn't support this action. Sub test() With Application.FileSearch .NewSearch .LookIn = "C:Documents and SettingsDesktopCommercial Database" .SearchSubFolders = True .Filename = "*.*" .TextOrProperty = "BANK" .MatchAllWordForms = True .FileType = msoFileTypeAllFiles If .Execute() > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." End If End With End Sub Additional info:- The 1st line of my code which is With Application.FileSearch is highlighted in yellow when I run this macro.
View Replies!
View Related
Macro Doesn't Work On Button, But Fine From Macro Menu!
I've recorded a macro that copies an entire tab into a new spreadsheet then goes on the copy and paste information from one tab to another. When I run the macro from the Tools>Macros menu it works perfectly. But when I copy the code and add it to that of a button it fails and posts the following error: Run-time error '1001': Select method of Range class failed. The first attachement shows the code for the macro as it is alone, and the second shows how I simply copied and pasted it into the 'view code' window of the button. Needless to say I'm a beginner at macros and only every record them, I can usually make stuff work that way but this has me stumped!
View Replies!
View Related
Script Works In Debugger But Doesn't When Macro Runs
I am trying to do a very simple Macro for merging data. My problem is that the macro works when I am stepping through in debugger, but does not work when I am in excel and I use the shortcut key (crtl + m) to run the macro. What happens when it doesn't work properly is it selects rows 2 and 3 and tries to paste them to the new workbook and I get an error saying the cells are not the correct type. I don't want it to do this because rows 2 and 3 are titles and have nothing to do with the data I am moving. As I said before, when I open VBE and step through the code it works just fine. The error only happens when there is no data on the initial work sheet.
View Replies!
View Related
Insert Picture Macro Doesn't Work In 2007
I just upgraded to Excel 2007 and my macro from Excel 2003 for inserting a picture doesn't work correctly in 2007. I have a command button that states insert picture and when you click it, it will let you insert a picture into the cell and hide the command button. In 2007 it will let you insert the picture, but it isn't centered and expands into other cells and the command button is still visible. The picture appears to be the correct size it just doesn't center itself in the cell and the command button is still visible. Below is the
View Replies!
View Related
Recorded Macro Doesn't Seem To Provide Expected Result
On column A, I simply do an A-Z sort that gives the expected result. So I recorded it as a macro. In column G is a code that corresponds with column A. When the marcro is executed Column A is sorted but the corresponding value in G stays where it is. Clicking the A-Z button works. But when that action is recorded as a macro I get the above quirck. Since VBA is not my beef, I don't really know what wrong.
View Replies!
View Related
Macro Doesn't Work When Workbook/File Is Shared
I am encountering a specific scenerio where In I am creating a New file by copying one of the sheets And renaming that With todays date. here starts me problem when I try To share the sheet To work around I am seeing that th macro Is Not copying the sheet properly even though i have given PasteSpecial. The code goes here VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing Is Not transferred when copy/pasting, but Is If the keyword uses "quotes". Sub Newsheet() sheetname = Format(Now, "dd-mmm-yyyy") MsgBox sheetname sheet_count = Worksheets.Count 'Checking for Replication................
View Replies!
View Related
Run-time Error '1004' :: Method 'Range' Of Object'_Global' Failed
I am trying to create a macro in my personal macro book such that whenever any workbook is opened the calculation settings (tools, options, calculation tab) are set to semiautomatic and do not calculate before save. The macro works when I am opening Excel itself (Book1) but when I open an already saved file it gives me Run-time error '1004' Method 'Range' of object'_Global' failed From there I choose Debug, the VBE window comes up, and I hit F5 to continue the code without doing any actual debugging. Here is the code that I am using. This is in the Personal Macro book on the "This Workbook" section....
View Replies!
View Related
Run-time Error '1004' Method 'Range' Of Object '_Worksheet' Failed
I have an interesting error that only happens when there is one row of data in the worksheet (sheet2 or "Half Payout"). Rows 1 & 2 are headers, row 3 is when the data starts - if any. With either no rows of data or more than one the coding works just fine. Here is the exact error message I'm getting: Run-time error '1004': Method 'Range' of object '_Worksheet' failed. The following code is supposed to sort the rows of data when opened and then activate the first open cell below B2.
View Replies!
View Related
Run-time Error '1004': Methd 'Range' Of Object '_Global' Failed
I have constructed the following code to set the print area of worksheets that have been selected to print to the range referenced in a worksheet level named range "xPrintArea". This named range is set using the OFFSET function. The procedure also sets the left footer to be a copyright notice that is also contained in a cell referenced by a named range. Set oPrintArea = Range(sPrintAreaName) is generating the error "Methd 'Range' of object '_Global' failed". Note that the line Set oCopyrightNotice = Range("CopyrightNotice") does not generate this error. From what I've been able to determine from other research on this forum and others, I believe the problem is that I need to more fully qualify the object which Range(sPrintAreaName) is referencing. I've already tried to use Set oPrintArea = wkSht.Range(sPrintAreaName).................
View Replies!
View Related
Method 'Add' Of Object 'CommandBarControls' Failed (run-time Error '-2147467259')
i get this error on the line in bold Method Add' of object 'CommandBarControls' failed (run-time error '-2147467259'). im not sure why its giving that problem, but im not very fluent in custom toolbars. '//The following two procedures add a custom menu to the workbook programmatically//' '//and then delete it//' Public currentMonth As String Sub CreateMenu() Dim mybar As CommandBar Dim myControl As CommandBarControl Set mybar = Application.CommandBars.Add( Name:="CustomButtons", _ Position:=msoBarBottom, Temporary:=True) mybar.Visible = True Set myControl = mybar.Controls _ .Add(Type:=msoControlButton, ID:=1) With myControl...........................
View Replies!
View Related
Import Macro Trying To Gain Acces To File That Doesn't Exist.
I get the following error: "Run-time error '1004': "cmc4906.xls" File cannot be found. Check the spelling of the file name and verify that the file location is correct." I am not trying to open a xls file. The path is clear and there are no file names with extensions in the path name (C:Weekly). I'm unclear of why the code thinks its looking for file cmc4906.xls and a xls file at that. Sub Import() Dim inputfile As Variant Dim path As Variant path = ("C:Weeklys") inputfile = Dir("C:Weeklys") Do While inputfile <> "" Workbooks.OpenText Filename:=inputfile, Origin:=437, StartRow _ :=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _ ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, Comma:=False, _ Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), Array(2, 1), Array( _ 3, 1), Array(4, 1), Array(5, 2), Array(6, 2), Array(7, 1), Array(8, 1), Array(9, 1), Array(10 _.............
View Replies!
View Related
Protecting Worksheet With Macro (Run Time Error '1004')
I am using the following code to enable users of a form to made make selections by adding a tick in one of the boxes by clicking on it. It works fine with thesheet unpotected but when I protect the sheet with cells E33:k33 unlocked i get Run Time Error '1004' Unable to set the Name property of the font class.When I debug, Target.Font.Name = "Marlett" is highlighted.
View Replies!
View Related
Run-time Error '1004' :: Copying Data From Other Sheets By Macro
I've been trying to use the below code, Sub combine() 'This will copy data from all sheets of the selected workbooks 'To a sheet named 'Data' in the sheet in which the macro is run from Dim pasterow As String mainsheetname = ActiveWorkbook.Name MsgBox ("Please select spreadsheets to combine") filestoopen = Application.GetOpenFilename(MultiSelect:=True)...
View Replies!
View Related
Macro To Print Active Area Excluding Cells With Forumula That Doesn't Return Value
Trying to put together a macro that looks down active sheet for all cells that contain a value, sets a print area and then prints ! Is this possible? FYG, I have a column that run from 3 - 2000, which contains a formula, which may produce a value depending on corresponding cells. I used this code from a post on a similar topic, but excel is complaining code in bold Private Sub Print_Area_Click() Dim lastCell As Range Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 0) Do Until Application.Count(lastCell.EntireRow) 0 Set lastCell = lastCell.Offset(-1, 0) Loop ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address End Sub
View Replies!
View Related
Run Time Error 1004 - Method 'Range' Of 'Object'_Global' Failed
I am trying to build a macro which will format the columns of a spreadsheet - basically it inserts some columns, writes formulas and highlights them. Here is a code I have got so far... When I try to run this I get a run time error 1004 - Method 'Range' of 'Object'_Global' failed. The part of the code Range("N2:N").FormulaR1C1 = "=(RC[-7]/RC[-2])" is highlighted in the debugger. Can anyone tell me why this is happening, also it would be great if you could suggest better ways of writing this code - as I am new to vba programming and most of my macros are built using the recorder and then 'working' on them.
View Replies!
View Related
Hyperlink Does Not Cause 'worksheet_activate' Macro To Run
I have the following Private Sub Worksheet_Activate() Application.ScreenUpdating = False updateall = MsgBox("Do you want to update the previous balance?", vbYesNo) If updateall = vbYes Then ActiveSheet.Unprotect ' clear previous payments Range("U3").Select Range(Selection, Selection.End(xlDown)).Select Selection.ClearContents ' update previous balance Range("H54").Select Selection.Copy Range("G11").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Range("D7").Select ActiveSheet.Protect End If Application.ScreenUpdating = True End Sub Now, this works just fine if the user clicks the sheet itself. However, generally they are accessing sheets via hyperlinks, which do not seem to activate this code. Is there a better/different way to ensure when the user gets to a sheet via hyperlink, they still see the msgbox?[/b]
View Replies!
View Related
Run-time Error '1004' Method 'Add' Of Object ' Sheets' Failed Adding Multiple Sheets
I have been running a simulation for about 18 hours now and just received: Run-time error '1004': Method 'Add' of object ' Sheets' failed I have been creating new sheets, importing data, pulling some values from the data then deleting the respective sheet. I am using: ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count) The sheet is actually being added to the workbook, seemingly before the error. I resume the code, and a new sheet is placed in the workbook and it errors again. The Debugger stops and highlights on the code above.The sheet count number was 10895 at the error, just as an indicator of how many times the simulation has performed successfully. I am hoping this is something I can fix without having to start over...
View Replies!
View Related
"Run-time Error '1004', Method ' Range' Of Object '_Global' Failed"
I keep getting this "Run-time error '1004', Method ' Range' of object '_Global' failed" Here is the code that has the problem: Option Explicit Dim i As Long Dim j As Long Dim lDup As Long Dim lRow As Long Dim NoDupes As Collection Dim rRng As Range Dim Rng1 As Range Dim Rng2 As Range Dim Rng3 As Range Dim Swap1 As Variant Dim Swap2 As Variant Dim wks As Worksheet Private Sub UserForm_Initialize() Call DefaultSet For lDup = 1 To 3 Call NonDuplicatesList(lDup) Next lDup End Sub..................... It does not even loop once though the original UserForm_Initialize For/Next loop.
View Replies!
View Related
Crashes On 2nd Run
I have the following code which filters data in a sheet, and loads the numbers into textboxes on a userform. There are two multipage controls, each with several textboxes on them. I have commented out several lines because if I leave any of them in, it crashes excel. It will work once. But if I close the workbook, re-open it, and run the code again, it crashes. The thing I find really interesting is that all the 'problem lines' were added in as part of a retro-fit. The person I created this workbook for needed one more column of data. I followed the same programming pattern as what I used on the other, but only these ones seem to cause problems. Any thoughts? NOTE: The message boxes were just to help me figure out which lines of code were causing the crash. ....
View Replies!
View Related
Run-Time Error '1004' Cannot Open PivotTable Source File 'Consolidated Report'
I have a macro that takes the date from different excel sheets, consolidates the data and renders the pivot table and chart accordingly. It was working fine when the date range defined for the pivot table was static. Now I have made it dynamic since the data range changes each month depending on the number of days it has got. When I run the macro, it runs succesfully, generates the report and save & close the report, but after that I am getting this error. Errorneous
View Replies!
View Related
Macro For 'Save As'
I want to specify a button that have the function of prompting the user to save the file as new file name. I tried to do the record macro, but I think it's not working as I wanted to. Can any expert teach me the code? As I was creating a standard form (excel file), I don't want the users to overwrite the current file name.
View Replies!
View Related
Doesn't Work If The Worksheet Hasn't Been Saved Yet
I'm trying to simplify a formula that I'm using in a spreadsheet that's being used mostly in Excel 2000. 2 reasons I'm doing this: 1) It doesn't work if the worksheet hasn't been saved yet. 2) It's ugly =DATE(YEAR(DATEVALUE(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,3) & " 20" & MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+5,2))),MONTH(DATEVALUE(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,3) & " 20" & MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+5,2)))+1,0) The formula returns the last day of the month of the name of the sheet. For example, if the sheet is names "Mar 07", it returns 3/31/07. (yeah, when the 2100 issue becomes a big deal, I'm not going to be ready but I have 92 years to think about it) Even if I can't make it prettier, does anyone have a way to get the sheet name into a formula without VBA Code in a file that hasn't been saved.
View Replies!
View Related
Open Workbook, Run Macro, Save - Automate
I have 5 Excel files. The first one is Main, and the other 4 are subfiles, namely A1, A2, A3 & A4. I have a need to open Main, then click a button to start a Macro (in Main) which will do the following, sequentially: 1. open A1 2. run a Macro in A1 3. close and save A1. 4. open A2 5. run a Macro in A2 ... 12 close and save A4. The files A1..A4 are a file server and being shared. If they're being used by another user, it cannot be saved - so I would have to skip it and continue with the next A. It would be great if start Excel, open Main, and run the Macro in Main fully automatically.
View Replies!
View Related
Run-time Error '1004' :: Run On Other Computer
I have a piece of VB code that works perfectly on my pc. The spreadsheet has been emailed to a partner (different company) and the code no longer works and they get the run-time error. Private Sub cmdPrintandsave_Click() Dim Company As String Dim irow As Long Dim MyDate MyDate = Date Dim wsD As Worksheet Dim wsD1 As Worksheet Set wsD = Worksheets("AppBDataSheet") Set wsD1 = Worksheets("AppBPrintable") Company = Application.OrganizationName Application.ScreenUpdating = False................
View Replies!
View Related
Auto Answering Save As Dialogue Box During Macro Run
I have written a macro which opens a worksheet, performs various operations on it, and closes it again. The problem is that upon close, two separate dialogue boxes appear - one asking me if I want to save, the other asking me if I want to keep what I have copied in the clipboard. Is there a way of answering these dialogue boxes (or suppressing them) from withint he macro, so I do not need to manually click on Yes or No each time the macro is run?
View Replies!
View Related
Both 'Private Sub Workbook_Open' And 'Auto Open' Run Sequentially
I have built a complex vba & multisheet spreadsheet that I am looking to secure against all the common attacks. So I have:A Workbook Open pw; VBA password (29 symbols/numbers/Caps/lower case) Very Hidden worksheets Hidden rows/columns Restricted scroll areas Workbook protection Code that auto protects all sheets upon opening Registry referencing in Workbook Open with timed closure if not matched Now I am on the last leg of implementing protection against Application.EnableEvents = False; force enabling of Macros and hiding of toolbars, scrollbars etc... Phew. Soooo, in my research, I have learnt that if EnableEvents = False, Workbook_Open is essentially skipped and the security VBA routines are disabled. To get around, I have copied the entire contents of the Workbook_Open routine to a module under Auto_Open. The first line of both these scripts is: Application.EnableEvents = True. Works! So far so good. However, I have a Msgbox prompt in the scripts that displays twice. So in essence, Excel is running Workbook Open first, then Auto Open second. If I open another instance of Excel and run Application.EnableEvents = False first before opening my spreadsheet, I only get one message. So only the Auto Open script runs.
View Replies!
View Related
Adding Folder To 'Open' And 'Save As' Windows
I had this set up in Excel 2003, but our main shared drive just went down and after remapping this link didn't work. How do I do this in Excel 2007? I want a folder to show up on the left hand side of the "Open' and 'Save As' windows under My computer, desktop, My Documents, etc.
View Replies!
View Related
My Macro Won't Run For Other People
It runs fine for me, but when others (who are using Excel 2003) try to run it, it won't fire. The second macro entitled "Delete Foothill" runs fine though. "Run Foothill won't fire. Sub Run_Foothill() Sheets("Foothill Plaza (Weekly Call)").Unprotect Password:="Foothill" ' ' Run_Foothill Macro ' ' Sheets("OC").Select Range("B37:C44").Select Selection.Copy Sheets("Foothill Plaza (Weekly Call)").Select Range("B4").Select ActiveSheet.Paste Range("A12").Select Application.CutCopyMode = False Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone Selection.Borders(xlEdgeLeft).LineStyle = xlNone With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With
View Replies!
View Related
Don't Run Macro On First Three Sheets
After searching through other threads I was able to gather the following code to copy worksheet titled Week 1 and paste it to the remaining 51 worksheets in the workbook: Sub CopyCols() Dim ws As Worksheet For Each ws In Worksheets If ws. Name <> "Week 1" Then Sheets("Week 1").Range("A1:N" & Rows.Count).Copy ws.Range("A1:N" & Rows.Count) Next ws End Sub The problem I am having is that I have 3 summary worksheets before the Week 1 worksheet and I need these sheets to not be affected by the above macro.
View Replies!
View Related
Intermittent Crash When Running Macro
I have having alot of frustation with a big group of Macro's I have written, all the macros work and run fine most of the time but they crash Excel on occasion and the only way I have been able to fix it is to go into Visual Basic and opening the project up (it is password protected) but not making any changes, after doing this it seems to magically stop crashing, for a while, then doing it again. I can't work out how or why that would make a difference, I dont expect you to try and work out a problem in the code or anything like that cause it is too big and would be unreasonable of me to ask, What I would like to know is if anyone else is aware of this sort of issue, why it happens and if there is any good cure for it? I am running excel 2003 if that also makes any difference.
View Replies!
View Related
Run-time Error '429' ActiveX Component Can't Create Object
I am trying to generate excel report output from access by click of a button. Part of the code is as follows: Dim lngColumn As Long Dim xlx As Object, xlw As Object, xlc As Object Dim DBS As DAO.Database Dim rst As DAO.Recordset Dim blnEXCEL As Boolean, blnHeaderRow As Boolean blnEXCEL = False 'If we do not want the first row we set Header to false blnHeaderRow = False 'Establish an EXCEL application object On Error Resume Next Set xlx = GetObject(, "Excel.Application") If Err.Number <> 0 Then Set xlx = CreateObject("Excel.Application") blnEXCEL = True End If Err.Clear I worked on development on a server and worked fine. However when I have moved the code and database to the desktop of mine I am having the following error in the line Set xlx = GetObject(, "Excel.Application") Run-time error '429' ActiveX component can't create object
View Replies!
View Related
Run-time Error '91' When 'On Error Goto' And Cells.find
I have written a Excel (2003) that searches a worksheet for a string in any cell. If the string is not found, it uses the 'On Error GoTo' command to jump to a given label. It works fine on the first string not found. When it searches for the next non-existent string, it fails with: 'Run-time error '91': Object variable or With block variable not set' Do I have to clear a buffer after each cells.find search? My
View Replies!
View Related
Hyperlink Doesn't Work
I have a hyperlink to [url] that doesn't work. When I click it I get an error saying "Unable to locate the server or proxy server". But when I cut & paste the address from the hyperlink into my browser (no chance of mistyping), it works fine.
View Replies!
View Related
Validation Drop Down Doesn't Appear
I named a range State, it contains a list of all the US state abbreviations. I do a data validation that refers to this range as a List. If I type in something that's not in the named range I get the error message I created for the Validation. But - I don't get a drop down button. I tried to do the same validation on another cell and get the same thing. Other drop downs for validation appear.
View Replies!
View Related
Right Click Doesn't Work
As said, the right click doesn't work anymore, last week it was working but it doesn't anymore. When I right-click wherever in the spreadsheet nothing happens but I know it's working because it works outside excel.
View Replies!
View Related
Listbox Doesn't Redraw
I have a worksheet with a listbox from the controls toolbox. I have to use the controls toolbox activex version because the box is formatted and I don't want a vertical scrollbar. I don't want to use a userform either because that would be major overkill. When the view is set to full screen the listbox partially disappears. Paging up and paging down will redraw the screen and the listbox. I've tried application.screenupdating with different listbox events but nothing works.
View Replies!
View Related
Choose Sheets That Save Or Don't Save
I have 120 sheets in my workbook and I only need 5 of them to save when there are changes, the other 115 are were data is pulled from. Is it possible to tell excel not to look at a sheet when it saves? I'm just after making it save faster. This is going to be a workbook that " moves" a round a lot, so I want to the 115 sheets in the same workbook.
View Replies!
View Related
|