Help Using xlUP

business_analyst

Board Regular
Joined
Jun 5, 2009
Messages
99
Hello All,

So I have a list located in Column A of a worksheet. This master list is actually comprised of several smaller lists, each separated by an empty cell (e.g. A1:A5, A7:A14, A16:A21) The empties cells here would be A6 and A15. I have included a button on this sheet that I would like to use to delete these mini-lists one at a time starting from the last one. This is the code I have:

Code:
Sub Erase_List()
    Do While Sheet5.Cells(Rows.count, 1).End(xlUp).Offset(-1, 0).Value = ""
        Sheet5.Cells(Rows.count, 1).End(xlUp).Value = ""
    Loop
end sub
I am trying to recognize the empty cell between each list in order to allow each section to be deleted one click at a time. The code above is working except for the fact that it is not erasing the cell just below the empty cell between lists. For example if there is data in:

A1:A5 and A7:A14
the above code will delete the data located in cells A8:A14, but leave A7 alone.

Basically I don't know how to get the code to stop exactly on the empty cells between lists.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Instead of a loop I'd try a native approach. Edit-->Goto (Ctrl+G)-->Special-->Blanks, then delete the selected rows.

If it does what you want it's easily recorded.

HTH,
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top