ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete rows w/o hardcoding numbers (https://www.excelbanter.com/excel-programming/345989-delete-rows-w-o-hardcoding-numbers.html)

Dave B[_9_]

delete rows w/o hardcoding numbers
 
I'd like to delete a group of rows. Normally I would do:

Rows("12:45").Delete Shift:=xlUp

But the row numbers are stored in variables. I can't do (causes an
error):

Rows("intBeginDelete:intEndDelete").Delete Shift:=xlUp

I can do it using a For...Next loop, deleting the rows one at a time,
but I'm working with lots of row groups & files and that makes
execution slow. Is there an easier/faster way to do this?


Dave Peterson

delete rows w/o hardcoding numbers
 
Rows(intBeginDelete & ":" & intEndDelete).Delete

might work ok.


Dave B wrote:

I'd like to delete a group of rows. Normally I would do:

Rows("12:45").Delete Shift:=xlUp

But the row numbers are stored in variables. I can't do (causes an
error):

Rows("intBeginDelete:intEndDelete").Delete Shift:=xlUp

I can do it using a For...Next loop, deleting the rows one at a time,
but I'm working with lots of row groups & files and that makes
execution slow. Is there an easier/faster way to do this?


--

Dave Peterson

Dave B[_9_]

delete rows w/o hardcoding numbers
 
Thanks for the suggestion. It gives me a Type Mismatch error. Any
idea why?


Dave Peterson

delete rows w/o hardcoding numbers
 
I'd guess that one (maybe both) your variables aren't what you expect:


Dave B wrote:

Thanks for the suggestion. It gives me a Type Mismatch error. Any
idea why?


--

Dave Peterson


All times are GMT +1. The time now is 05:39 PM.

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