#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Identifying Weekends

Hi,
Im seeking some kind of help here

Ive got a range of dates given by DATE function (01-16-2007 01-17-2007
01-18-2007, etc.), i've also formated the cells so to get only the name of
the day (Mon-Tue-Wed, etc).

But Now Im trying to get a macro to identify Weekends so to get an action
done, lets say for example, to insert 3 rows after each Sunday.
Obviously i cant program something like : If range ("x") = "Sunday" then....
Since those are real dates.

Id appreciate any kind of help

Thanx in advance
Jepane

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Identifying Weekends

Option Explicit
Sub testme()
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long

With Worksheets("sheet1")
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
If Weekday(.Cells(iRow, "A").Value) = vbSunday Then
.Rows(iRow).Resize(3).Offset(1, 0).Insert
End If
Next iRow
End With
End Sub

If you're doing this to make the report look prettier, maybe just increasing the
rowheight would be better. You could increase the rowheight of the next row or
increase the rowheight of the Sunday row--and change it so that the vertical
alignment is at the Top.

Inserting rows into raw data can screw up other stuff--filters, charts,
pivottables...

Jepane wrote:

Hi,
Im seeking some kind of help here

Ive got a range of dates given by DATE function (01-16-2007 01-17-2007
01-18-2007, etc.), i've also formated the cells so to get only the name of
the day (Mon-Tue-Wed, etc).

But Now Im trying to get a macro to identify Weekends so to get an action
done, lets say for example, to insert 3 rows after each Sunday.
Obviously i cant program something like : If range ("x") = "Sunday" then....
Since those are real dates.

Id appreciate any kind of help

Thanx in advance
Jepane


--

Dave Peterson
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
Identifying textcolor FreddieP Excel Discussion (Misc queries) 3 April 17th 07 07:56 PM
Identifying famdamly Excel Discussion (Misc queries) 2 February 26th 06 06:44 AM
Identifying #N/A cells Lee Harris Excel Worksheet Functions 1 November 18th 05 02:57 AM
vba, identifying a range Danny Excel Worksheet Functions 1 August 2nd 05 08:17 PM
Identifying links Andrew Excel Discussion (Misc queries) 2 June 30th 05 01:17 PM


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