+ Reply to Thread
Results 1 to 16 of 16

xlDown error when active cell is the last row.

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    xlDown error when active cell is the last row.

    Super basic (and wrong) code as you can see. If you have a list of ten names (A1:A10) and you select name ten, then this macro will throw an error. The error is because between A10:A15 is empty cells, but A16 is a merge cell.

    Basically, I just want the macro to do xlDown UNLESS there is no value in the cell right below it. This would make A10, become A11. I cannot insert a row, or cut because that screws other cell's formulas up.



    Please Login or Register  to view this content.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    this test just before your copy line should help you
    Please Login or Register  to view this content.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Excuse the ignorance. Does that go under "Range"?

    I would still want that single select cell copied down. I know it is just as easy to manually do it, but this file will be used by others, and I don't want to have to tell them to do this, but not when that. You know what I mean.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    how about this:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Same error. Can't do that because of Merged cell.

    I attached the calculator. You'll see what I mean, but stay between the yellow boxes. Macro locks the workbook. Password is "QA"
    Attached Files Attached Files

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    maybe you should explain in more details what you want to do.
    Can you also give is examples of desired results?

  7. #7
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Like in the sample workbook. You have a list of dates. I want to select a date, run the macro and it moves that date and any dates below it, down one row. You cannot cut/copy or just insert row because it will mess up other cell's formulas. What my macro is basically taking the activecell and then ctrl+down. This works fine when there are cells with values below it. But if there is not any cells with values, then it wants to keep highlight until it finds the bottom yellow cell.

    I am just wanting to bump the selected cell, and any cells in that table, down one row.

  8. #8
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    what happen with the last month value if all rows have data in it? It disappears?
    What happen if there is an empty cell in the middle of the month? Are the values in the months below moved down also?
    Or do the previous months move down till it meets the empty cell without disturbing the last months?

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Disappearing would be ok, but generally no, nothing would happen because there is no month after the last cell, so that date has no where to go.

    Do you mean in the middle of the year? There shouldn't be because you should enter the payment dates in sequential order. Not skipping cells. If you want to move a date to following month, then that is where this macro comes in. I think if I can just stop it from selecting anything below the active cell if there is an empty row beneath it, then that would work.

    Right now when it is locked and everything, if I try to ctrl+shift+down nothing happens. That is the same thing I want to happen with the macro. When unlocked, it will select the empty cells until it hits the bottom Yellow cell. So if the macro would act the same, then it would be fine.

  10. #10
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Can I do a bump...

  11. #11
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    try this macro:
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Thank you. I think that is exactly what I am looking for. Can you explain what you did so I can learn? I follow everything pretty much, except the ">= 15 Then "

  13. #13
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    The macro first check if the XlDown bring you at or below the row of the month December which is in row 15.
    If so, then it clears the content of the month December then it limits the range selection till row 14 (14 - ActiveCell.Row) so that when selected it has room to be pasted.
    If not, then it works like you programmed it.

  14. #14
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    The december part doesn't matter though it seems? Which is good, December may not always be in row 15. Because if you make your first payment today then April 2018 would be in row 15

  15. #15
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: xlDown error when active cell is the last row.

    it does not matter which month it is as long as it is in row 15.
    If your table length is going to change then we'll need some changes to get it work in all cases.

  16. #16
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: xlDown error when active cell is the last row.

    Nope. The original calculator that this is based on hasn't changed in over a year, so I don't expect that to happen anytime soon!


    Thank you!

+ 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. “Selection.Insert Shift:=xlDown” gets Run-time error '1004'
    By watsonea4 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-02-2023, 07:07 AM
  2. active.Cell compile error
    By forestPeterson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2011, 03:07 PM
  3. troubleshoot xlUp xlDown error 1004
    By LowSociety in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-13-2010, 11:48 AM
  4. compile error on simple End.xldown code
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-23-2010, 09:06 AM
  5. Use Xldown to find cell, but ignor Formula in cells
    By t0m46 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2010, 07:46 AM
  6. [SOLVED] xlDown stops at next empty cell, not at last row of data
    By Ronny Hamida in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2006, 08:20 AM
  7. End(xldown) not always going to last cell?
    By Duncan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-04-2006, 05:35 AM
  8. Unable to get last filled cell address from Range.End(xlDown) method
    By vedpatel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2006, 05:15 AM

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