Macro - Deleting Rows

Matt_Chelmsford

Board Regular
Joined
Jan 31, 2009
Messages
156
Good afternoon everyone,

It looks like it's going to be very nice this weekend in the South east/London area. Just typical, why could it not have been nice last weekend when I saw Springsteen?

ANyway here is my problem

cell H58 is the start of my data (ignoring headings) and in column H I have sequential numbering, so H58 is 1.

The data range goes over to column M.

I have successfully put in a macro where the user just hits the button and it adds a line in. For example if there are 12 rows then it can add 13, 14, 15,etc just by hitting the button.

I need a macro that does the opposite where it goes down to the last number and deletes the cells H:M.

Grateful for any help!

kind regards

Matthew
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
You can attach this to a button.

Code:
Sub delLast()
Dim sh As Worksheet, lr As Long
Set sh = Sheets(1) 'Edit sheet name
lr = sh.Cells(Rows.Count, "H").End(xlUp).Row
Range("H" & lr).Resize(1, 6).Delete
End Sub
Code:
 

TryingToLearn

Well-known Member
Joined
Sep 10, 2003
Messages
723
or try this:

Code:
Sub HM()
    Dim LRw
    LRw = Range("H" & Rows.Count).End(xlUp).Row
    Range("H" & LRw & ":M" & LRw).Delete
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,324
Messages
5,600,956
Members
414,417
Latest member
Nobu

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
Top