Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default deleting record with a range

I have a range of rows with data withi them. say 100 rows. on the
sheet theres acell in which you enter a number say 20. And the
program deletes all the rows within the range except the first 20, I
am using a very simple code at the moment but i am sure could be done
better

counter = Range("e11")
Range("e15").Select
Do Until countert = counter
ActiveCell.Offset(1, 0).Select
countert = countert + 1
Loop

Do Until ActiveCell = ""
ActiveCell.EntireRow.Delete
Loop

as you see the user determines the number of records he wants by
entering a number in range E11.

This does work fine but I am trying to learn better programming
methods where I am not actively moving around a worksheet, any
suggestions
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default deleting record with a range

counter = Range("e11")
FirstRow = 15
DeleteRow = FirstRow + counter
LastRow = Range("E" & Rows.Count).End(xlup).Row
rows(DeleteRow & ":" & Lastrow).Delete

" wrote:

I have a range of rows with data withi them. say 100 rows. on the
sheet theres acell in which you enter a number say 20. And the
program deletes all the rows within the range except the first 20, I
am using a very simple code at the moment but i am sure could be done
better

counter = Range("e11")
Range("e15").Select
Do Until countert = counter
ActiveCell.Offset(1, 0).Select
countert = countert + 1
Loop

Do Until ActiveCell = ""
ActiveCell.EntireRow.Delete
Loop

as you see the user determines the number of records he wants by
entering a number in range E11.

This does work fine but I am trying to learn better programming
methods where I am not actively moving around a worksheet, any
suggestions

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
how to combine each record into a range? pemt Excel Discussion (Misc queries) 2 March 26th 10 06:37 PM
Copy a record before deleting Shinu Excel Programming 3 February 15th 06 08:43 AM
Copy a record before deleting Tom Ogilvy Excel Programming 0 February 5th 06 03:33 AM
Deleting a record from Access data base using programming from excel dipak Excel Programming 1 October 18th 05 02:49 PM
Deleting Range name's listed in the range address box. Satnam Patel Excel Discussion (Misc queries) 4 May 5th 05 01:42 PM


All times are GMT +1. The time now is 10:46 PM.

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

About Us

"It's about Microsoft Excel"