#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Macro to delete rows

Hello

I would like a macro that deal with this task.

I have Range from A1:H385.

After sorting, a number of rows will have 999 in AX, BX and CX.

The number of rows with this condition will vary, depending on how
busy the process is going to be.

I would like a macro to delete these and from Row386 to Row500.

Many thanks for your time.

Aj
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro to delete rows

Hi,

In your message header you ask to delete rows and in the body of the message
you seem to say delete the values. This does the latter. Right click your
sheet tab, vuew code and paste this in and run it

Sub stance()
Dim MyRange
Dim copyrange As Range
Set MyRange = Range("AX386:AX500")
For Each c In MyRange
If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(, 52).Value =
999 Then
Set copyrange = Union(c, c.Offset(, 26), c.Offset(, 52))
copyrange.ClearContents
Set copyrange = Nothing

End If
Next
End Sub

Mike

"Hankjam" wrote:

Hello

I would like a macro that deal with this task.

I have Range from A1:H385.

After sorting, a number of rows will have 999 in AX, BX and CX.

The number of rows with this condition will vary, depending on how
busy the process is going to be.

I would like a macro to delete these and from Row386 to Row500.

Many thanks for your time.

Aj

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Macro to delete rows

Arrgghh

Sorry. I meant to delete the rows...

I'll give this a go and see what happens

Many thank Mike

Aj


On Wed, 1 Oct 2008 07:08:06 -0700, Mike H
wrote:

Hi,

In your message header you ask to delete rows and in the body of the message
you seem to say delete the values. This does the latter. Right click your
sheet tab, vuew code and paste this in and run it

Sub stance()
Dim MyRange
Dim copyrange As Range
Set MyRange = Range("AX386:AX500")
For Each c In MyRange
If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(, 52).Value =
999 Then
Set copyrange = Union(c, c.Offset(, 26), c.Offset(, 52))
copyrange.ClearContents
Set copyrange = Nothing

End If
Next
End Sub

Mike

"Hankjam" wrote:

Hello

I would like a macro that deal with this task.

I have Range from A1:H385.

After sorting, a number of rows will have 999 in AX, BX and CX.

The number of rows with this condition will vary, depending on how
busy the process is going to be.

I would like a macro to delete these and from Row386 to Row500.

Many thanks for your time.

Aj

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Macro to delete rows

On Wed, 1 Oct 2008 07:08:06 -0700, Mike H
wrote:

Hi,

In your message header you ask to delete rows and in the body of the message
you seem to say delete the values. This does the latter. Right click your
sheet tab, vuew code and paste this in and run it

Sub stance()
Dim MyRange
Dim copyrange As Range
Set MyRange = Range("AX386:AX500")
For Each c In MyRange
If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(, 52).Value =
999 Then
Set copyrange = Union(c, c.Offset(, 26), c.Offset(, 52))
copyrange.ClearContents
Set copyrange = Nothing

End If
Next
End Sub

Mike


Hi

Got some Syntax error on the line:

If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(,
52).Value = 999

The range of the Data is A1:H385

Rows 102 to 385 have 999 in columns A

It is these rows and those from 386 to 500, which are empty I want to
delete.

The starting row with 999 in column A can vary.

Thank you

Andrew
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro to delete rows

Use this to delete the entire row

Sub stance()
Dim MyRange
Dim copyrange As Range
Set MyRange = Range("AX386:AX500")
For Each c In MyRange
If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(, 52).Value =
999 Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If

If Not copyrange Is Nothing Then
copyrange.Delete
End If

Mike

"Hankjam" wrote:

On Wed, 1 Oct 2008 07:08:06 -0700, Mike H
wrote:

Hi,

In your message header you ask to delete rows and in the body of the message
you seem to say delete the values. This does the latter. Right click your
sheet tab, vuew code and paste this in and run it

Sub stance()
Dim MyRange
Dim copyrange As Range
Set MyRange = Range("AX386:AX500")
For Each c In MyRange
If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(, 52).Value =
999 Then
Set copyrange = Union(c, c.Offset(, 26), c.Offset(, 52))
copyrange.ClearContents
Set copyrange = Nothing

End If
Next
End Sub

Mike


Hi

Got some Syntax error on the line:

If c.Value = 999 And c.Offset(, 26).Value = 999 And c.Offset(,
52).Value = 999

The range of the Data is A1:H385

Rows 102 to 385 have 999 in columns A

It is these rows and those from 386 to 500, which are empty I want to
delete.

The starting row with 999 in column A can vary.

Thank you

Andrew

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
My Macro Won't Delete Rows?? VexedFist New Users to Excel 3 April 16th 07 04:14 PM
Delete all Rows Macro Wanna Learn Excel Discussion (Misc queries) 5 March 6th 07 10:06 PM
Macro to Delete Certain Rows HROBERTSON Excel Discussion (Misc queries) 2 February 8th 07 09:42 PM
delete rows using macro nospam Excel Worksheet Functions 5 December 20th 06 01:26 PM
delete rows-macro TUNGANA KURMA RAJU Excel Discussion (Misc queries) 5 January 13th 06 12:01 PM


All times are GMT +1. The time now is 02:53 AM.

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"