+ Reply to Thread
Results 1 to 7 of 7

Macro using end(xlDown) and End(xlToRight))

  1. #1
    Forum Contributor
    Join Date
    08-09-2006
    Posts
    145

    Macro using end(xlDown) and End(xlToRight))

    I have a macro that I found and I need to make some changes. However, I'm not that familiar with VBA so I need some help.


    What I need it to do is select range A1 end right and range end down. Maybe like this : "If Range("A1", Range("A1").End(xlDown).End(xlToRight)).Select
    I don't know how to put it in the code below.

    Goal is to take all the 0 and blank cells and clear them.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,538

    Re: Macro using end(xlDown) and End(xlToRight))

    How about this.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    08-09-2006
    Posts
    145

    Re: Macro using end(xlDown) and End(xlToRight))

    How do I incorporate it into my Macro. I need a Dim statement or something? Can you put it in the statement for me?

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    Posts
    2,447

    Re: Macro using end(xlDown) and End(xlToRight))

    No selecting needed.
    You indicate to clear, not delete, cells with a zero (0). I don't think you have to worry about clearing blank cells.

    One possibility:
    This will replace all zeros on the whole sheet.

    Please Login or Register  to view this content.
    If you want to delete cells, maybe up or left, that would be a different story


    This will delete the Cells with a Zero (0) and shift up.
    Please Login or Register  to view this content.
    This will delete the Zeros and shift blank Cells up.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 02-12-2019 at 01:41 PM. Reason: Additional info added

  5. #5
    Forum Contributor
    Join Date
    08-09-2006
    Posts
    145

    Re: Macro using end(xlDown) and End(xlToRight))

    Still not quite there. It maybe simpler to just delete all lines below the last line. I have attached an example. I just need all the blank lines below the data to be deleted.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    08-09-2006
    Posts
    145

    Re: Macro using end(xlDown) and End(xlToRight))

    I posted an example spreadsheet.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,538

    Re: Macro using end(xlDown) and End(xlToRight))

    Try this.
    Please Login or Register  to view this content.

+ 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