+ Reply to Thread
Results 1 to 5 of 5

Range Offset Error 1004

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Range Offset Error 1004

    Hi, I am using the following macro to format a sheet - I recently added a auto-fill part to it which essentially moves a number from one column to another and autofills it in all the cells until it encounters another number of the same kind in the column it moved the previous number from. When I try to run this macro it does everything upto the auto-fill part and then gives me error 1004 [the set cell = cell.offset(1,0) ] is highlighted in yellow.
    I cannot figure out what could be wrong, I would appreciate your help with this!!
    Thanks.

    Please Login or Register  to view this content.
    Last edited by excelaspire0219; 02-03-2009 at 03:47 PM. Reason: Added Code tags, title

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: debugging attached macro

    Hello excelaspire0219,

    The title of your post is important. The more descriptive your title is about your problem, the more likely you are to receive a fast response. It will help you get your question answered quickly and correctly as well as help other members and guests to find answers to the same or similar problem.

    A better title would be "Range Offset Error 1004".

    If you need helping in changing the title of your post let me know. Click here to send me a message.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Range Offset Error 1004

    Whilst looping through the cells if an exact match of END OF REPORT is not found then you will continue to loop to the last row and get an error message when trying to set a range beyond the last row



    To test add this code immediatle before your Set Cell = Cell.Offset(1, 0) command

    Please Login or Register  to view this content.
    I notice you are also selecting columns before deleting them.
    In VBA Selecting is rarely required

    As an example this code
    Please Login or Register  to view this content.
    Can be replaced with
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Range Offset Error 1004

    Thanks Mudraker. It turns out that I was adding a column before doing the the move, therefore although the number I was looking for was in column B it moved to column D just before that segment of the code ran. Your solution helped me detect this - thanks again

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Range Offset Error 1004

    Glad to hear I helped you solve your problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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