+ 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
    147

    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
    MO Prof Plus 2016
    Posts
    6,907

    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
    147

    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
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    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
    147

    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
    147

    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
    MO Prof Plus 2016
    Posts
    6,907

    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)

Similar Threads

  1. Macro to create chart using XLtoRight Variable for adding column data
    By Hondahawkrider in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-07-2016, 11:54 PM
  2. # TRANSPOSE function macro with Selection.End(xlToRight)
    By paulmacro in forum Excel General
    Replies: 1
    Last Post: 01-29-2015, 07:12 AM
  3. Macro Autofill xlDown
    By vincent76 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2014, 04:32 PM
  4. how do xltoright -1???
    By uttam.mothe in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-29-2013, 08:35 AM
  5. xltoright
    By c7015 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2012, 01:10 PM
  6. xlDown and xlToLeft in a vlookup in a macro
    By Jeremy.S in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-06-2010, 10:12 PM
  7. [SOLVED] Problems with AutoFill xlDown macro on certain computers - DESPERA
    By marika1981 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-24-2005, 09:06 PM

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