Excel Run-time Error 1004

Anonymous
2019-03-31T04:36:52+00:00

I am a college student learning spreadsheets. My assignment is to make a macro and then run it to make sure it works. I made the macro, but when I tried to run it in another worksheet of the same workbook, I get the following error:

Microsoft Visual Basic:

Run-time error '1004'

Application-defined or object-defined error

I hit the debugging button on the error message

it highlighted a section but I don't know how to fix the problem. 

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2019-03-31T04:43:33+00:00

    Hello JMichelleXB!

    I am Ofir an independent adviser willing to help.

    Enter the following link and perform the instructions that are indicated to resolve error 1004

    https://support.microsoft.com/en-us/help/178510...

    If you have another question, I am here to help you.

    Greeting.

    1 person found this answer helpful.
    0 comments No comments
  2. Andreas Killer 144K Reputation points Volunteer Moderator
    2019-03-31T07:22:52+00:00

    The RTE 1004 means nothing and occurs in different scenarios... more or less "something unspecific gone wrong, don't know why".

    The basic problem of your code is that you use SELECT and SELECTION. Please never use SELECT, SELECTION, ACTIVECELL, it is slow and error prone. Always refer to the objects directly.

    The Offset is a property of the Range object
    https://docs.microsoft.com/en-us/office/vba/api...

    And if you want to Select the 5th column from the active cell, this obvious can not work if you are in column A to D...

    Range("A:D").ColumnWidth = 21
    

    That works regardless what is selected.

    Andreas.

    3 people found this answer helpful.
    0 comments No comments