Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Change the range for a recordset?

I need to delete the rows with a positive number in a specific column. The
recordset will vary each time it is run. How do i change the range?



Sub click()
Dim i As Integer
Sheet1.Select
Sheet1.Range("a2:b6").Select
For i = 2 To 6
Cells(i, 2).Select
If Sheet1.Cells(i, 2) 0 Then Sheet1.Rows(i).Delete
Next i
End Sub
Exit Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Change the range for a recordset?

It depends on what the criteria for the recordset is. Here is a
solution assuming you want the macro to operate on the value in the
first column of the selected range:

Sub click()
Dim i As Long
With Selection
For i = .Cells(1,1).Row + .Rows.Count - 1 to .Cells(1,1).Row Step
- 1
If .Cells(i,1) 0 Then .Cells(i,1).EntireRow.Delete
Next
End With
End Sub

Charles Chickering

marthasanchez wrote:
I need to delete the rows with a positive number in a specific column. The
recordset will vary each time it is run. How do i change the range?



Sub click()
Dim i As Integer
Sheet1.Select
Sheet1.Range("a2:b6").Select
For i = 2 To 6
Cells(i, 2).Select
If Sheet1.Cells(i, 2) 0 Then Sheet1.Rows(i).Delete
Next i
End Sub
Exit Sub


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 can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
How to populate Excel Range from Access RecordSet? deko[_2_] Excel Programming 6 February 27th 05 03:43 PM
Creating a recordset over a range James Excel Programming 3 December 10th 04 05:16 AM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
open range (within workbook) as ado recordset - excel vba S. Daum Excel Programming 0 July 25th 03 04:45 PM


All times are GMT +1. The time now is 09:31 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"