Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Delete a range of rows ?


I made this code to delete a range of rows, but I found out
that this code only delete every second row.

Do Until Worksheets("Materielplacering").Cells(lCurrentRow, 4).Value = ""
Worksheets("Materielplacering").Rows(lCurrentRow). Delete
lCurrentRow = lCurrentRow + 1
Loop

I need to delete some rows, starting from row X to Y
It must be possible to make it like Range.(X,Y).delete
or something like that, but I'm not sure how to write
this single line of code.






--
Mit fotoalbum
www.photo.activewebsite.dk


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete a range of rows ?

Do Until Worksheets("Materielplacering").Cells(lCurrentRow, 4).Value = ""
Worksheets("Materielplacering").Rows(lCurrentRow). Delete
Loop

as you delete, the next row will become the current row, so you don't need
to increment lCurrentRow

--
Regards,
Tom Ogilvy

"SpookiePower" wrote in message
. dk...

I made this code to delete a range of rows, but I found out
that this code only delete every second row.

Do Until Worksheets("Materielplacering").Cells(lCurrentRow, 4).Value = ""
Worksheets("Materielplacering").Rows(lCurrentRow). Delete
lCurrentRow = lCurrentRow + 1
Loop

I need to delete some rows, starting from row X to Y
It must be possible to make it like Range.(X,Y).delete
or something like that, but I'm not sure how to write
this single line of code.






--
Mit fotoalbum
www.photo.activewebsite.dk




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Delete a range of rows ?

So simple :) Thanks.

But what if I want to delete a range of rows from X to Y. How do I
write the "Range-Delete" line ?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete a range of rows ?


With Worksheets("Materielplacering")
For i = Y To X Step -1
If .Cells(i, 4).Value = "" Then
.Rows(i).Delete
End If
Next i
End With

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"SpookiePower" wrote in message
ups.com...
So simple :) Thanks.

But what if I want to delete a range of rows from X to Y. How do I
write the "Range-Delete" line ?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Delete a range of rows ?

Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete a range of rows ?

X = 10
Y = 30

lCurrentRow = X
With Worksheets("Materielplacering")
.Cells(lCurrentRow, 1).Resize(Y-X+1,1).EntireRow.Delete
End With

--
Regards,
Tom Ogilvy


"SpookiePower" wrote in message
ups.com...
So simple :) Thanks.

But what if I want to delete a range of rows from X to Y. How do I
write the "Range-Delete" line ?



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Delete a range of rows ?

Thanks. I'll take a look at it later to day.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If Count is not in a certain range, delete Rows CarolynRatcliffe Excel Discussion (Misc queries) 0 February 23rd 10 04:52 AM
Select a range of rows to delete Donna[_3_] Excel Worksheet Functions 2 January 26th 10 07:32 PM
delete rows in range - macro hindu cliparts Excel Worksheet Functions 0 November 16th 06 09:54 PM
Delete Rows & Capture Range sameer27p[_22_] Excel Programming 3 August 5th 04 05:43 AM
Delete all Rows in a Variable Range John[_78_] Excel Programming 3 June 30th 04 06:13 PM


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"