Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting row based on critéria using VBA
HI, I would like to insert a row when a certain cell has a certain value. The ideia is to divide the values into weeks, inserting an empty row after every sunday (where I wiil put the totals of the week), and group the whole week in order to see just the week total. Can anyone help me doing this in VBA? -- RSantos ------------------------------------------------------------------------ RSantos's Profile: http://www.excelforum.com/member.php...o&userid=31240 View this thread: http://www.excelforum.com/showthread...hreadid=516687 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting row based on critéria using VBA
Dim oRow As Range For Each oRow In Selection.Rows If Weekday(oRow.Cells(1, 1).Value) = 1 Then oRow.Offset(1, 0).Insert End If Next oRow -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "RSantos" wrote in message ... HI, I would like to insert a row when a certain cell has a certain value. The ideia is to divide the values into weeks, inserting an empty row after every sunday (where I wiil put the totals of the week), and group the whole week in order to see just the week total. Can anyone help me doing this in VBA? -- RSantos ------------------------------------------------------------------------ RSantos's Profile: http://www.excelforum.com/member.php...o&userid=31240 View this thread: http://www.excelforum.com/showthread...hreadid=516687 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting row based on critéria using VBA
This tests a date in cloumn A to see if is a Sunday and then inserts a row. Adjust to suit your needs HTH Sub InsertRow() With Worksheets("Sheet1") ' <=== change as required lastrow = .Cells(Rows.Count, "A").End(xlUp).Row For r = lastrow To 2 Step -1 If Weekday(.Cells(r, "A"),2) = 7 Then ' <== change test to suit your needs .Cells(r, "A").Offset(1, 0).EntireRow.Insert End If Next r End With End Sub "RSantos" wrote: HI, I would like to insert a row when a certain cell has a certain value. The ideia is to divide the values into weeks, inserting an empty row after every sunday (where I wiil put the totals of the week), and group the whole week in order to see just the week total. Can anyone help me doing this in VBA? -- RSantos ------------------------------------------------------------------------ RSantos's Profile: http://www.excelforum.com/member.php...o&userid=31240 View this thread: http://www.excelforum.com/showthread...hreadid=516687 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting row based on critéria using VBA
RSantos Wrote: HI, I would like to insert a row when a certain cell has a certain value. The ideia is to divide the values into weeks, inserting an empty row after every sunday (where I wiil put the totals of the week), and group the whole week in order to see just the week total. Can anyone help me doing this in VBA? Sub ValSunday() ' Range("A9").Select If Selection.Value = "Sunday" Then 'your code here End If End Sub copy and paste this in a normal module, create a button and assin this macro to it: once you work on the code and add other code that meets your specs, you can then paste it into your worksheet change event but thats another story work on the macro first -- davesexcel ------------------------------------------------------------------------ davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708 View this thread: http://www.excelforum.com/showthread...hreadid=516687 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Query criteria based on a changing criteria list | Excel Discussion (Misc queries) | |||
Vlookup with 2 different criteria before inserting a value | Excel Discussion (Misc queries) | |||
inserting a row based on a condition. | Excel Worksheet Functions | |||
Inserting a worksheet based on a template | Excel Programming | |||
Inserting rows based on count | Excel Programming |