Runtime error 1004 application

runtime error 1004 application

Range issue or Protected mode issue or something else? Check these threads for fixes. VBA Runtime Error 1004 “Application-defined or. Excel runtime error 1004 typically comes up when. excel.officetuts.net › vba › vba-runtime-error-1004-application-defined-or.

Runtime error 1004 application - necessary

Automation error (Error 440) Out of Memory (Error 7)

The VBA Runtime Error 1004 can be caused by many things. In this article, I’ll show a few different situations and show how to deal with them.

Tutorial Content

VBA code refers to a range that doesn’t exist

This code usually happens when VBA code refers to a cell or range that doesn’t exist. For example, this code is correct.

Sub myFunc()     Set Rng = Worksheets("Sheet1").Range("Z3")     Set Rng2 = Worksheets("Sheet1").Range("ZZ3") End Sub

But when you try to access the following ranges, the program will return an error in both cases.

Sub myFunc()     '>>>Error 1004 "Application-defined or Object-defined error"     Set Rng = Worksheets("Sheet1").Range("ZZZ3")     Set Rng2 = Worksheets("Sheet1").Range("myRange") End Sub

The first line returned 1004 error because Excel contains only 16,384 columns and the last column is XFD. In the second case, we don’t have the “myRange” range. In this case, the application also returns the error. After you create the range, the error won’t show up.

You should really pay attention when you are using loops, especially for columns. You can go out of the index without noticing.

You are trying to enter a value that is not a range

The following code will result in an error because the program cannot recognize values inside the Range property as a range.

Sub myFunc()     '>>>Error 1004 "Application-defined or Object-defined error"     Set Rng = Worksheets("Sheet1").Range(4)     Set Rng2 = Worksheets("Sheet1").Range("4") End Sub

Select a worksheet explicitly

Sometimes when you choose a worksheet implicitly, you may have 1004 error.

Take a look at this code. Here, you selected the active sheet, but when you activate a different sheet this may result in an error.

Set wksSource = ActiveWorkbook.ActiveSheet

Instead, use the code when you explicitly select sheet name.

Set wksSource = ActiveWorkbook.Sheets("Sheet1")

You are using protected mode

You may also get the 1004 error if your worksheet is in the protected mode. Disabling the protection might get rid of this error.

Macro recorded at the worksheet level

Sometimes you may get this error if you record a macro at the worksheet level. You should create a module and enter the code there. In order to do so, go to VBE (Alt + F11) and right click on the module’s icon. Insert a new module and enter your code there.

These situations are the most common for error 1004 to occur. I hope it fixed your problem.

Post Views:83,857

Type Mismatch (Error 13)

When you get the error again, go into DEBUG and determine the values for the variables involved and ensure that they are all legitimate values.  You may find that one is not valid - for example, rw1 might be zero, or it might be so large that rw1+8 is greater than the number of rows permitted for the worksheet.  It could also be that the active workbook doesn't contain a sheet named as whatever is in strt_stmp.

 

Your statement doesn't actually totally clear the contents of the cells, it places a zero length string into them.  To actually clear the contents you might consider using

 

Worksheets(strt_stmp).Range(Cells(rw1, cl1), Cells(rw1 + 8, cl1)).ClearContents

 

Another possibility might be that the worksheet is protected which would prevent the change to the values in those cells if they are locked.

I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein

27 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi,

 

If the variables are defined and have appropriate values then that will work if the worksheet strt_stmp is the activesheet. If it isn't the active sheet then you get the runtime error you describe.

If this response answers your question then please mark as answer.

Mike H

26 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I'm having the same issue as the original poster. Is there way to access the range without having to activate the sheet?

Thanks for any help.

Nick

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes, you can reference any worksheet regardless of which one is active by specifically using it in the reference, as:

Worksheets("the_sheet_name_shown_on_its_tab").Range(range reference).property_or_method

As

cellA5Value = Worksheets("Sheet1").Range("A5")

.value is implied when used like that but you can be explicit

cellA5Value = Worksheets("Sheet1").Range("A5").Value

You can also reference them by their relative position in the workbook (and cross your fingers that a user doesn't move them around), as

cellA5Value = Worksheets(1).Range("A5")

would get the value of A5 in the first/left-most sheet in the workbook.

A little better way is to set an 'object' as a reference to the worksheet and then use that object when you want to reference it as:

Dim myWS As Worksheet

Set myWS = Worksheets("Sheet3")

then you can write code like this from that point

cellA5Value = myWS.Range("A5")

There's an even better way, using what is called the sheet's Code Name in your VBA code: code that uses this method will continue to work even if someone changes the name shown on a sheet's tab or moves it around in the workbook.  You can read about it in Section 2 (starts on page 2) of this little thing I put together a while back:

http://www.jlathamsite.com/Teach/VBA/WritingBulletProofCode.pdf

I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi JLLatham,

I've been using the latter methond you decribed in your code to refer to a worksheet i.e.

Dim myWS As Worksheet

Set myWS = Worksheets("Sheet3")



It has worked for me up until recently. I've been trying to quite a large array (10000 rows, 37 columns)back to the worksheet but get the "Excel VBA run-time error 1004 : Application-defined or object-defined error" if the worksheet isn't selected; however it appears to run when the worksheet is selected. Do you have any ideas as to what could be going wrong/or how to fix this?

629 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

My macros are not working, for example our taxes we download them from the internet and then we find the template and validate and generate other worksheet which we submit. We are receiving the message which is saying "macro basic error 1004". Could I be restored to my previous setting because the computer was formated and thus the problem came. 

Looking forward to your quick response.

Regards,

Kenneth Ngalamika.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Dear Sir,

Am waiting to hear from you soon so that I can make your service good.

4 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 

 

Invalid Procedure Call Or Argument (Error 5) Object Doesn’t Support this Property or Method (Error 438)

 Summary:

In this post, I have included the complete information about Excel runtime error 1004. Besides that I have presented some best fixes to resolve runtime error 1004 effortlessly.

To fix Runtime Error 1004 in Excel you can take initiatives like uninstalling Microsoft Work, creating a new Excel template, or deleting The “GWXL97.XLA” File. If you don’t have any idea on how to apply these methods then go through this post.

Here in this article, we are going to discuss different types of runtime error 1004 application error 1004 in Excel along with their fixes.

What Is Runtime Error 1004 In VBA Excel?

Excel error 1004 is one such annoying runtime error that mainly encounters while working with the Excel file. Or while trying to generate a Macro in Excel document and as a result, you are unable to do anything in your workbook.

This error may cause serious trouble while you are working with Visual Basic Applications and can crash your program or your system or in some cases, it freezes for some time. This error is faced by any versions of MS Excel such as Excel 2007/2010/2013/2016/2019 as well.

To recover lost Excel data, we recommend this tool:

This stop c000221 unknown hard error will prevent Excel workbook data such as BI data, financial reports & other analytical information from corruption and data loss. With this software you can rebuild corrupt Excel files and restore every single visual representation & dataset to its original, intact state in 3 easy steps:

  1. Download Excel File Repair Tool rated Excellent by Softpedia, Softonic & CNET.
  2. Select the corrupt Excel file (XLS, XLSX) & click Repair to initiate the repair process.
  3. Preview the repaired files and click Save File to save the files at desired location.

Error Detail:

Error Code: run-time error 1004

Description: Application or object-defined error

Screenshot Of The Error:

run-time error 1004

Don’t worry you can fix this Microsoft Visual Basic runtime error1004, just by following the steps mentioned in this post. But before approaching the fixes section catch more information regarding runtime error1004.

Excel VBA Run Time Error 1004 Along With The Fixes

EXCEL ERRORS

The lists of error messages associated with this Excel error 1004 are:

  1. VB: run-time error ‘1004’: Application-defined or object-defined error
  2. Excel VBA Runtime error 1004 “Select method of Range class failed”
  3. runtime error 1004 method range of object _global failed visual basic
  4. Excel macro “Run-time error ‘1004″
  5. Runtime error 1004 method open of object workbooks failed
  6. Run time runtime error 1004 application ‘1004’: Method ‘Ranger’ of Object’ Worksheet’ Failed
  7. Save As VBA run time Error 1004: Application defined or object defined error

Let’s discuss each of them one by one…!

#1 – VBA Run Time Error 1004: That Name is already taken. Try a different One

This VBA Run Time Error 1004 in Excel mainly occurs at the time of renaming the sheet.

If a worksheet with the same name already exists but still you are assigning that name to some other worksheet. In that case, runtime error 1004 application, VBA will throw the run time error 1004 along with the message: “The Name is Already Taken. Try a different one.”

VBA Run Time Error 1004 in Excel 1

Solution: You can fix this error code by renaming your Excel sheet.

#2 – VBA Run Time Error 1004: Method “Range” of object’ _ Global’ failed

This VBA error code mainly occurs when someone tries to access the object range with wrong spelling or which doesn’t exist in the worksheet.

Suppose, you have named the cells range as “Headings,” but if you incorrectly mention the named range then obviously you will get the Run Time Error 1004: Method “Range” of object’ _ Global’ failed error.

VBA Run Time Error 1004 in Excel 2

Solution: So before running the code properly check the name of the range.

# 3 – VBA Run Time Error 1004: Select Method of Range class failed

This error code occurs when someone tries to choose the cells from a non-active sheet.

 Let’s understand with this an example:

Suppose you have selected cells from A1 to A5 from the Sheet1 worksheet. Whereas, your present active worksheet is Sheet2.

At that time it’s obvious to encounter Run Time Error 1004: Select Method of Range class failed.

VBA Run Time Error 1004 in Excel 3

Solution: To fix this, you need to activate the worksheet before selecting cells of it.

#4 – Dell system timer error Runtime Error 1004 method open of object workbooks failed

This specific run time Error 1004 arises when someone tries to open an Excel workbook having the same workbook name that is already open.

In that case, it’s quite common to encounter VBA Runtime Error 1004 method open of object workbooks failed.

VBA Run Time Error 1004 in Excel 4

Solution: Well to fix this, first of all close the already opened runtime error 1004 application having a similar name.

#5 – VBA Runtime Error 1004 Method Sorry We Couldn’t Find:

The main reason behind the occurrence of this VBA error in Excel is due to renaming, shifting, or deletion of the mentioned path.

The reason behind this can be the wrong assigned path or file name with extension.

When your assigned code fails to fetch a file within your mentioned folder path. Then you will definitely get the runtime Error 1004 method. Sorry, and We couldn’t find it.

VBA Run Time Error 1004 in Excel 5

Solution: make a proper check across the given path or file name.

#6 – VBA Runtime Error 1004 Activate method range class failed

Behind this error, the reason can be activating the cells range without activating the Excel worksheet.

This specific error is quite very similar to the one which we have already discussed above i.e Run Time Error 1004: Select Method of Range class failed.

VBA Run Time Error 1004 in Excel 6

Solution: To fix this, you need to activate your excel sheet first and then activate the sheet cells. However, runtime error 1004 application, it is not possible to activate the cell of a sheet without activating the worksheet.

Why This Visual Basic Runtime Error 1004 Occurs?

Follow the reasons behind getting the run time error 1004:

  1. Due to corruption in the desktop icon for MS Excel.
  2. Conflict with other programs while opening VBA Excel file.
  3. When filtered data is copied and then pasted into MS Office Excel workbook.
  4. Due to application or object-defined error.
  5. A range value is set programmatically with a collection of large strings.

Well, runtime error 1004 application, these are common reasons behind getting the VBAruntime error 1004, now know how to fix it. Runtime error 1004 application we have described both the manual as well as automatic runtime error 1004 application to fix the run time error 1004 in Excel 2016 and 2013. In case you are not able to fix the error manually then make use of the automatic MS Excel Repair Tool to fix the error automatically.

How To Fix Runtime Error 1004?

Fix Runtime Error 1004

Follow the steps given below to fix Excel run time error 1004 :

1: Uninstall Microsoft Work

2: Create New Excel Template

3: Delete The “GWXL97.XLA” File

Method 1: Uninstall Microsoft Work

1. Go to the Task Manager and stop the entire running programs.

2. Then go to Start menu > and select Control Panel.

run time error 1004 (1)

3. Next, in the Control Panel select Add or Remove Program.

run time error 1004 (2)

4. Here, you will get the list of programs that are currently installed on your PC, and then from the list select Microsoft Work.

run time error 1004

5. And click on uninstall to remove it from the PC.

It is also important to scan your system for viruses or malware, runtime error 1004 application this corrupts the files and important documents. You can make use of the temple of terror 2005 download antivirus program to remove malware and also get rid of the runtime error 1004.

Method 2: Create New Excel Template

Another very simple method to fix Excel runtime error 1004 is by putting a php su display error Excel worksheet file within a template. Instead of copying or duplicating the existing worksheet.

Here is the complete step on how to perform this task.

1.Start your runtime error 1004 application application.

2. Make a fresh new Excel workbook, after then delete the entire sheets present on it leaving only a single one.

3. Now format the workbook as per your need or like the way you want to design in your default template.

4. Excel 2003 user: Tap to the File>Save As option

SAVE EXCEL FILE

OR Excel 2007 or latest versions: Tap to the Microsoft Office button after then hit the Save As option.

SAVE EXCEL FILE 1

5. Now in the field of File name, assign name for your template.

6. On the side of Save as type there is a small arrow key, make a tap on it. From the opened drop menu

  • Excel 2003 users have to choose the Excel Template (.xlt)

Create New Excel Template 1

  • And Excel 2007 or later version have to choose the Excel Template (.xltx)

Create New Excel Template 2

7. Tap to the Save.

8. After the successful creation of the template, now you can programmatically insert it by making use of the following code:
Add Type:=path\filename

Remarks:

From the above code, runtime error 1004 application, you have to replace the path\filename with the complete path including the file name. For assigning the exact location of the sheet template you have just created.

Method 3: Delete The “GWXL97.XLA” File

Follow another manual method to fix Excel Runtime Error 1004:

1. Right-click on the start menu.

2. Then select the Explore option.

Excel Runtime Error 1004

3. Then open the following directory – C:\Program Files\MSOffice\Office\XLSTART

Excel Runtime Error 1004 (1)

4, runtime error 1004 application. Here you need to delete “GWXL97.XLA” file

Excel Runtime Error 1004 (2)

5, runtime error 1004 application. And open the Excel after closing the explorer

You would find that the program is running fine without a runtime error. But if you are still facing the error then make use of the automatic MS Excel Repair Tool, to fix the error easily.

Automatic Solution: MS Excel Repair Tool

MS Excel Repair Toolis a professional recommended solution to easily repair both .xls and .xlsx file. It supports several files in one repair cycle. It is a unique tool that can repair multiple corrupted Excel files at one time and also recover everything included charts, cell comments, worksheet properties, runtime error 1004 application, and other data. This can recover the corrupt Excel file to a new blank file. It is extremely easy to use and supports both Windows as well as Mac operating systems.

Download       Buy Now

* Free version of the product only previews recoverable data.

Steps to Utilize MS Excel Repair Tool:

Conclusion:

Hope this article helps you to repair the runtime error 1004 in Excel and recovers Excel file data. In this article, we have provided a manual as well as automatic solution to get rid of Excel run-time error 1004. You can make use of any solution according to your desire.

Good Luck!!!



Summary

How To Repair Runtime Error 1004 In Excel

Article Name

How To Repair Runtime Error 1004 In Excel

Description

Try best fixes to resolve Excel the war z error error 1004. METHOD 1: Uninstall Microsoft Work, runtime error 1004 application, METHOD 2: Create New Excel Template, METHOD 3: Delete The "GWXL97.XLA” File AND MORE…

Author

Sandra Louis

Publisher Name

Repair MS Excel Blogs

Publisher Logo

Repair MS Excel Blogs

Priyanka Runtime error 1004 application src="https://www.repairmsexcel.com/blog/wp-content/uploads/2022/06/WhatsApp-Image-2022-06-16-at-10.10.37-AM-150x150.jpeg" height="70" width="70">

Priyanka is an entrepreneur & content marketing expert. She writes tech blogs and has expertise in MS Office, Excel, runtime error 1004 application, and other tech subjects. Her distinctive art of presenting tech information in the easy-to-understand language is very impressive. When not writing, runtime error 1004 application, she loves unplanned travels.

Categories Excel ErrorsTags common runtime error 1004, error 1004, excel runtime error 1004, run time error 1004, Solutions for Runtime error 1004, Why this runtime error 1004 occur

Excel VBA run-time error 1004 Application-defined runtime error 1004 application object-defined error

Your comment on this question:

1 answer to this question.

Your answer

Your comment on this answer:

Related Questions In Database

Subscribe to our Newsletter, and get personalized recommendations.

Already have an account? Sign in.

webinarREGISTER FOR FREE WEBINARX
webinar_successThank you for registeringJoin Edureka Meetup community for 100+ Free Webinars each monthJOIN MEETUP GROUP

How to fix the Runtime Code 1004 Application-defined or object-defined error

Last Updated:

31/08/22 05:58 : A Windows 10 user voted that repair method 2 worked for them.


Recommended Repair Tool:


This repair tool can fix common computer problems such as blue screens, crashes and freezes, missing DLL files, as well as repair malware/virus damage and more by replacing damaged and missing system files.


STEP 1:
Click Here to Downloadand install the Windows repair tool.

STEP 2:
Click on Start Scanand let it analyze your device.

STEP 3:
Click on Repair Allto fix all of the issues it detected.

DOWNLOAD NOW

Compatibility

Requirements
1 Ghz CPU, 512 MB RAM, 40 GB HDD
This download offers unlimited scans of your Windows PC for free. Full system repairs start at $19.95.

Article ID: ACX02492EN


Applies To: Windows 10, Windows 8.1, Windows 7, Windows Vista, Windows XP, Windows 2000



Speed Up Tip #7

Turning Off Indexing in Windows:

One way to boost your Windows computer's performance is by turning off indexing. By default, the Windows Search indexing service is turned on. By turning it off for all local drives, you will get that increased speed you want.

Click Here for another way to speed up your Windows PC

Out of Memory (Error 7) runtime error 1004 application