We help IT Professionals succeed at work.
Get Started

Modify VBA Offset and Resize

Last Modified: 2012-08-13
I need help adjusting how rows get inserted and deleted with the macro in the attached file.  If you click the "Click to Insert" button and enter a positive number.  All formulas and formatting in the row above current position of cursor will copied.

If your cursor is positioned in row 4 for example, and you type "-2" in the dialog box, the macro will delete rows 4 and 5 from all select worksheets.  I would like to modify this to so that rows 3 and 4 would be deleted instead.  I'm fairly certain that this line of the code holds the key to making this happen.
ActiveSheet.Rows(sel).Resize(Abs(rng), 1).EntireRow.Select

Open in new window

However I have not had any luck properly applying it.  If someone could provide a recommendation and explain these two lines, I would be grateful.  Thanks!
ws.Cells(sel - 1, 1).Resize(rng + 1, 1).EntireRow.FillDown

Open in new window

ActiveSheet.Rows(sel).Resize(Abs(rng), 1).EntireRow.Select

Open in new window

P.S. I also attached the excel file that contains the complete code.  This should give you a better understanding to question.

Watch Question
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE