How to delete certain rows

Ron_N

New Member
Joined
Aug 25, 2011
Messages
30
Hi,

I am new to VBA. I want a code which needs to delete the count of rows which has exceeded the value of c. Suppose c stores a number, which is the number of rows to be kept and the rest of the rows deleted. I also want my header row to be the way it is. It should not be deleted.

Basically i want this
(Total number of rows - (c number of rows + the header row)).delete

I am using the following but not getting the desired result. Please help me out. Its urgent. I am stuck.

Rows .Resize(ActiveSheet.Range("a2", ActiveSheet.Range("a2").End(xlDown)).Count - c).Delete



Please assist.

Thank you,
Ron
 
HI Richard,


This worked perfectly.

I am so glad to have your guidance everytime i ask for it. Without your help i would have been stuck with the codes.

Thanks a billion for all your assistance.

Ron
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,224,578
Messages
6,179,654
Members
452,934
Latest member
mm1t1

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