Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Steve M
 
Posts: n/a
Default Deleting Row Macro


I have a spread sheet with data in A:A to G:G

I want a macro that will check the value in G and if its less than 3 to
delete that entire row and then move on to the next row and do the same


--
Steve M
------------------------------------------------------------------------
Steve M's Profile: http://www.excelforum.com/member.php...o&userid=32520
View this thread: http://www.excelforum.com/showthread...hreadid=534535

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Duke Carey
 
Posts: n/a
Default Deleting Row Macro

Insert a new column adjacent to your data and use it to insert row #s for all
your data. Now sort on column G so that all the rows less than 3 are in a
contiguous range. Delete them. Now sort on the rows numbers to restore your
data to its original order

"Steve M" wrote:


I have a spread sheet with data in A:A to G:G

I want a macro that will check the value in G and if its less than 3 to
delete that entire row and then move on to the next row and do the same


--
Steve M
------------------------------------------------------------------------
Steve M's Profile: http://www.excelforum.com/member.php...o&userid=32520
View this thread: http://www.excelforum.com/showthread...hreadid=534535


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Richard Buttrey
 
Posts: n/a
Default Deleting Row Macro

On Thu, 20 Apr 2006 08:02:35 -0500, Steve M
wrote:


I have a spread sheet with data in A:A to G:G

I want a macro that will check the value in G and if its less than 3 to
delete that entire row and then move on to the next row and do the same


One way.

First name the first cell in column G of your data as "StartRow"

I'm also assuming that there is something in all the cells in column
G. If not you'll need to change the lrows variable to something like
lrows=Range(Range("Startrow"),Range("G65536").End( xlUp)).Rows.Count


Sub DeleteGRowValue3()
Dim lRows As Long, x As Long
lRows=Range(Range("Startrow"),Range("Startrow").En d(xlDown)).Rows.Count

For x = lRows To 1 Step -1
If Range("startrow").Offset(x - 1, 0) < 3 Then
Range("startrow").Offset(x - 1, 0).EntireRow.Delete
End If
Next

End Sub


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
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
Deleting a macro scottech Excel Discussion (Misc queries) 5 December 5th 05 05:02 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
Deleting excess data in a macro ChuckW Excel Discussion (Misc queries) 3 February 24th 05 06:48 PM


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