Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Macro to delete rows

Hi Ken,

I have assumed that you have a column with dates. If so, then try the
following code. Note the comments where you may need to edit the the Sheet
name and then column identifier for the column with the dates.

If no column with dates then let me know and I will have another look at it.

Sub DeleteExceptFriday()

Dim lastRow As Long
Dim i As Long

'Edit "Sheet1" to your sheet name
With Sheets("Sheet1")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

'Must work backwards when deleting rows
'in a loop as follows.
'(to 2 assumes column header exists in row 1)
For i = lastRow To 2 Step -1

'Edit "A" to the column with your dates
If Weekday(.Cells(i, "A"), 1) < 6 Then
.Rows(i).Delete
End If
Next i
End With
End Sub

--
Regards,

OssieMac


"Ken G" wrote:

I have a list of daily data that is one day per row, I need a macro to trim
it back from daily data to weekly data retaining only Friday's data for each
week, so I need to delete 4 rows, skip a row and delete the next 4 rows etc.
The list is currently about 400 rows. (Excel 2003)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Macro to delete rows

Might need to edit "A" in the following line also to reflect the column with
your dates.

lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

--
Regards,

OssieMac

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
Macro to delete rows JeffF Excel Programming 12 March 18th 10 02:44 PM
Need a macro to delete rows jmr4h8 Excel Discussion (Misc queries) 9 July 2nd 08 11:16 PM
Macro to delete 2 rows every 500 rows [email protected] Excel Programming 3 February 3rd 08 01:52 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


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