Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Identifying textcolor | Excel Discussion (Misc queries) | |||
Identifying | Excel Discussion (Misc queries) | |||
Identifying #N/A cells | Excel Worksheet Functions | |||
vba, identifying a range | Excel Worksheet Functions | |||
Identifying links | Excel Discussion (Misc queries) |