+ Reply to Thread
Results 1 to 4 of 4

Application or object defined error - 1004

  1. #1
    Registered User
    Join Date
    07-04-2013
    Location
    Liverpool
    MS-Off Ver
    Excel 2007
    Posts
    21

    Application or object defined error - 1004

    Hi all

    I am having a problem with what would seem a simple peice of code the line I am having problems with is

    Please Login or Register  to view this content.
    I am fairly new to vba and have been trying a few methods and seem to having the same error, even after introducing more variables.

    Basically this is supposed to check existing cells except for the town and county cells for town and county names in other cells and clear the contents if this is true.

    I am guessing what evenr is the issue is a schoolboy error, there are some public variables used in this but they seem fine.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Application or object defined error - 1004

    Hi,

    Whenever you find yourself writing a looping macro take a step back and think if there is a more efficient and simpler way - there often is. Loops can be time consuming when many cells are involved.

    It's likely that the simplest way is to filter your data so that only the rows containing the cells you want to clear are visible and then clear those cells. Filtering is the fastest way I know to achieve this sort of stuff.

    Upload your workbook so that we can see the request in context and manually add the result you want to see on a second sheet.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Application or object defined error - 1004

    Please Login or Register  to view this content.
    You have not defined tcol in your Dim? What is tcol?

  4. #4
    Registered User
    Join Date
    07-04-2013
    Location
    Liverpool
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Application or object defined error - 1004

    There are two variables tcol and ccol.

    Variables tcol and ccol are from previous modules and declared publicly

    each contains the column number tcol = town column and ccol = county column

    I have had to do this because I am dealing with dynamic data where these columns could be different and are calculated dependant on the column where they reside.

    I have checked to contents of these variables and they are storing the correct value

    And I have just solved this issue, it was a schoolboy error and I had the variables declared as a string, I have changed them to long and it executes them fine.

    Thank you all for your help, you pointed me in the right direction.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Error 1004: Application-defined or object-defined error on Range(Cells(x,y)) syntax
    By winch in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 11:02 AM
  2. [SOLVED] application-defined/object-defined error 1004 when trying to read from or write to cells
    By florin_excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2012, 08:38 AM
  3. [SOLVED] run-time error '1004' application-defined or object-defined error - Excel 2007
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2012, 02:46 AM
  4. Replies: 2
    Last Post: 09-12-2012, 01:01 PM
  5. Replies: 0
    Last Post: 05-14-2012, 11:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1