Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Counter to delete a row

I have a macro which deletes row 6 from my worksheet.
eg "Rows("6:6").Select"
However I want to amend this code so that instead of deleting row 6 I want
to delete the row number equal to a counter value that I have defined.
When I come to a row I want to delete, what value do I put in the code
"Rows("?:?").Select" to delete the row number to the value of the counter.

thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Counter to delete a row

Hi Chris,

It is unnecessary to select a row in order to delete it. Normally, when
deleting rows, it is easier to start at the bottom and work up.

Perhaps try something like:

'=============
Public Sub Tester001()
Dim i As Long
Const startRow As Long = 2
Const endRow As Long = 100

For i = endRow To startRow Step -1
If Cells(i, "A").Value 10 Then
Rows(i).Delete
End If
Next i

End Sub
'<<=============


---
Regards,
Norman



"ChrisM" wrote in message
...
I have a macro which deletes row 6 from my worksheet.
eg "Rows("6:6").Select"
However I want to amend this code so that instead of deleting row 6 I
want
to delete the row number equal to a counter value that I have defined.
When I come to a row I want to delete, what value do I put in the code
"Rows("?:?").Select" to delete the row number to the value of the counter.

thanks for your help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Counter to delete a row

Thanks Norman,
However, I'm afraid I haven't been able to get that piece of code to work.
I'm probably doing something wrong so I'll persevere.

regards

Chris

"Norman Jones" wrote:

Hi Chris,

It is unnecessary to select a row in order to delete it. Normally, when
deleting rows, it is easier to start at the bottom and work up.

Perhaps try something like:

'=============
Public Sub Tester001()
Dim i As Long
Const startRow As Long = 2
Const endRow As Long = 100

For i = endRow To startRow Step -1
If Cells(i, "A").Value 10 Then
Rows(i).Delete
End If
Next i

End Sub
'<<=============


---
Regards,
Norman



"ChrisM" wrote in message
...
I have a macro which deletes row 6 from my worksheet.
eg "Rows("6:6").Select"
However I want to amend this code so that instead of deleting row 6 I
want
to delete the row number equal to a counter value that I have defined.
When I come to a row I want to delete, what value do I put in the code
"Rows("?:?").Select" to delete the row number to the value of the counter.

thanks for your help




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Counter to delete a row

Hi Chris,

Thanks Norman,
However, I'm afraid I haven't been able to get that piece of code to work.
I'm probably doing something wrong so I'll persevere.


Why not post your problematic code?


---
Regards,
Norman


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
1+2+3+4+........... Counter 23Hitamn Excel Discussion (Misc queries) 3 August 28th 07 10:17 AM
how do I set up a counter? John T Excel Discussion (Misc queries) 3 October 20th 06 09:01 PM
counter Haza Excel Discussion (Misc queries) 2 January 20th 06 08:30 PM
Counter Sdbenn90 Excel Discussion (Misc queries) 4 January 9th 06 11:43 AM
Counter Larry Hau Excel Programming 1 August 14th 03 11:00 PM


All times are GMT +1. The time now is 06:35 AM.

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"