ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delecting Rows (https://www.excelbanter.com/excel-programming/387081-delecting-rows.html)

Ayo

Delecting Rows
 
Does anyone know how to code this
I need to delete a bunch of rows but, the number of rows changes all the
time. I need to figure out a way to determine the number of rows that needs
to be deleted and delete them, at the same time shifting the other rows up.
All this has to be done by clicking a button.

Is there a o replace the 5 annd the 7 with variables representing numbers?
or is there any other way to accomplish the same task?

Any help will be greatly appreciated. Thank you.

Ayo

Worksheets(1).Rows("5: 7").Select
Selection.Delete Shift:=xlUp


Gary''s Student

Delecting Rows
 
Paste this macro in a standard module and attach it to a Forms button:

Sub ayo()
Dim s As String
s = Application.InputBox("enter rows to delete: ", 2)
Worksheets(1).Rows(s).EntireRow.Delete
End Sub

When the button is pushed, the input box will ask which rows to delete. You
answer something like 4:16
--
Gary''s Student - gsnu200714


Ayo

Delecting Rows
 
Thanks Gary, But what I want to do is much more involved than that. You see,
I have a form and on this form the are about 3 groups of rows that I need to
delete by clicking a reset button. The problem is the number for each group
of row varies everytime. And I don't want the people using this entering
values because andy wrong number enetered ad the whole form can get messed
up.
So, what I want to do is to writing a macro that will determine the number
of rows that must be deleted within each section of the form and then delete
those row. What I am looking for is a way to enter "4:16" in the code as
variables. I want to be able to do this:
Worksheets(1).Rows(strRow: endRow).Select
Selection.Delete Shift:=xlUp

Any other suggestions. Thanks

"Gary''s Student" wrote:

Paste this macro in a standard module and attach it to a Forms button:

Sub ayo()
Dim s As String
s = Application.InputBox("enter rows to delete: ", 2)
Worksheets(1).Rows(s).EntireRow.Delete
End Sub

When the button is pushed, the input box will ask which rows to delete. You
answer something like 4:16
--
Gary''s Student - gsnu200714



All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com