Excel Macro Runtime Error 1004
Contents |
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 13 Oct 2016 21:22:51 GMT by s_ac4 (squid/3.5.20)
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the runtime error 1004 vba company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions excel runtime error 1004 pivot table Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
Excel Runtime Error 1004 Sort Method Of Range Class Failed
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Excel macro “Run-time error '1004” up vote 0 down vote favorite I am new to scripting and I am trying http://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_winother/excel-vba-run-time-error-1004-application-defined/0211771e-8f9a-478a-9c61-ad00aaaaabfe to improve a existing Macro. I recorded a macro to remove dupliate and added it in a Main function which calls some other functions, but I am getting this error when I add the macro I recorded: Run-time error '1004': Application-defined or object-defined error. The code looks like Sub Main() Call DuplicateRemove Call DeleteBlankRows Call TrimText End Sub DeleteBlankRows() . . End Sub Sub TrimText() . . End Sub Sub DuplicateRemove() Columns("A:A").Select ActiveSheet.Range("$A$1:$A$95678").RemoveDuplicates Columns:=1, http://stackoverflow.com/questions/11746478/excel-macro-run-time-error-1004 Header:=xlNo End Sub Thanks, Kiran excel-vba share|improve this question edited Jan 30 '15 at 14:52 pnuts 33.8k63769 asked Jul 31 '12 at 18:17 Kiranshell 573510 On which line/routine are you getting the error? –LittleBobbyTables Jul 31 '12 at 18:23 I am getting the error only when I add the macro I recorded: Sub DuplicateRemove() Columns("A:A").Select ActiveSheet.Range("$A$1:$A$95678").RemoveDuplicates Columns:=1, Header:=xlNo End Sub –Kiranshell Jul 31 '12 at 18:44 Does Sub TrimText() . . imply that you actually have the words End Sub somewhere in there? –Brad Jul 31 '12 at 18:58 "'1004': Application-defined or object-defined error." effectively means that you have an unhandled error in your VBA code. Add error-handling with MSGBOX statements to see what the actual VBA error is... –RBarryYoung Jul 31 '12 at 21:45 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted There is nothing wrong with your code. You will only get this error if the Active worksheet is password protected. Also it is a much better option to avoid using .Select and ActiveSheet. Your code can be written as Sub DuplicateRemove() Dim ws As Worksheet Set ws = Sheets("Sheet1") With ws If .ProtectContents = True Then MsgBox "Worksheet is protected" .Unprotect "MYPASSWORD" .Range("$A$1:$A$95678").RemoveDuplicates Columns:=1, Header:=xlNo .Protect "MYPASSWORD" Else .Range("$A$1:$A$95678").RemoveDuplicates Col
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://stackoverflow.com/questions/17980854/vba-runtime-error-1004-application-defined-or-object-defined-error-when-select Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack http://www.speedypc.com/articles/fix_runtime_error1004.aspx Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBA Runtime Error 1004 “Application-defined or Object-defined error” error 1004 when Selecting Range up vote 7 down vote favorite 1 I am having an issue with a Error 1004 "Application-defined or Object-defined error" when selecting a range. I am still able to select rows (ie Rows("21:21").select) and to select ranges in other sheets of the same workbook. I do not believe the error is in the code. Maybe its some setting I am unaware of? I have time error 1004 used the exact same code many times before but for some reason I cannot make it function in this sub (I have commented where the error occurs)... Sub CopySheet1_to_PasteSheet2() Dim CLastFundRow As Integer Dim CFirstBlankRow As Integer 'Finds last row of content Windows("Excel.xlsm").Activate Sheets("Sheet1").Activate Range("C21").Select '>>>Error 1004 "Application-defined or Object-defined error" Occurs Selection.End(xlDown).Select CLastFundRow = ActiveCell.Row 'Finds first row without content CFirstBlankRow = CLastFundRow + 1 'Copy Data Range("A21:C" & CLastFundRow).Select Selection.Copy 'Paste Data Values Sheets("PalTrakExport PortfolioAIdName").Select Range("A21").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False 'Bring back to top of sheet for consistancy Range("A21").Select Range("A1").Select End Sub I need to get all fancy in my copying as the amount of rows will change frequently. Again, the below code has been used before without error... but not in this instance. Dim CLastFundRow As Integer Dim CFirstBlankRow As Integer 'Finds last row of content Windows("Excel.xlsm").Activate Sheets("Sheet1").Activate Range("C21").Select '>>>Error 1004 "Application-defined or Object-defined error" Occurs Selection.End(xlDown).Select CLastFundRow = ActiveCell.Row 'Finds first row without content CFirstBlankRow = CLastFundRow + 1 excel vba excel-vba share|improve this question edited Jul 27 '15 at 20:40 Mack M. 7501927 asked Jul 31 '13 at 20:58 thomas 36113 1 It's always best to avoid using Select
Windows users. These errors are particular to various Microsoft Office programs, including Microsoft Excel. The error that Excel users usually encounter is the Runtime Error 1004. This is a catch all error code which attempts to define errors that are essentially indefinable. Because of this, this type of error could actually point to a wide variety of problems. In this article, you will learn two of the common reasons for encountering Runtime Error 1004 and provide some tips to help resolve the problems. Symptoms of Runtime Error 1004 All runtime errors frequently give the user particular symptoms indicating that there's a problem. This error usually occurs when starting to open an Excel file or trying to access the Excel Desktop icon. You now see a Runtime Error 1004 message that says: "Method in Key up Object Program APPLICATION Failed." Some other details will inform you that the program is unable to load your resource library, suggesting that you must exit the application, installing the resource library again and restarting the program. You can actually troubleshoot your Excel problems and error 1004 within the Windows system. To do it, follow the steps below: Point your mouse to the Windows Start button and right-click In the menu tab, choose Explorer Once you get to Explorer, open the directory of C:\Program Files\MSOffice\Office\XLSTART Once you open the directory, delete the File named GWXL97.XLA Close the Explorer Open Excel After you open Excel, the program must start and enable you to work without the errors Related Runtime Errors in Worksheets You can also experience Runtime Error 1004 when doing some work with macros. We know that in Excel, we could run macros that duplicate or copies worksheets and put them in the workbook from which they were originally located. Doing so can result in a Error 1004. A message will pop up that reads: "object-defined error or application-defined" or "method of copying the worksheet failed." This usually occurs when you give your workbook a name