Forum Discussion
khjhzw
Mar 10, 2022Copper Contributor
How to insert (or create) new rows under every row that meets a certain condition?
Hello, Thank you for reading my question. Could you please help me with this task? I have to do a repetitive task with a quite a large excel worksheet (or table). I am wondering if there is w...
- Mar 10, 2022
Sub insertrow() Dim i As Integer Dim j As Integer For i = 1 To 1000 j = InStr(1, Cells(i, 1), "chapter", vbTextCompare) If j = 1 Then Cells(i + 1, 1).EntireRow.Insert Cells(i + 2, 1).EntireRow.Insert Cells(i + 1, 2).Value = "word count" Cells(i + 2, 2).Value = "date started" i = i + 2 Else End If Next i End Sub
Maybe with these lines of code. Click the button in cell E1 in the attached file to start the macro.
mrgcav
Oct 20, 2023Copper Contributor
OliverScheurich Similar to what I need. https://techcommunity.microsoft.com/t5/excel/how-to-insert-or-create-new-rows-under-every-row-that-meets-a/m-p/3254132 I have an excel 2019 form with 10 static data entry rows and columns A-AD (30). Some files have less than 10 entries. Some files have more than 10 entries. All cells have a formula with in them. Manually inserting new rows is slow. Rows 11-25 do various calculations on the inserted datas. Column C is always an integer, Column D are Alphanumeric, Column G is Alphanumeric text. If that matters. I do not know VBA or macros. but I know need a simple (background) macro to add/insert another row (row 11) when Cells 10C and 10D and 10G all have data. So by the time I fill in cell 10Z there is a row 11 and the cells in row 11 have a incremented formula. When Cells 11C and 11D and 11G all have data a row 12 is created. This repeats so I will always have one more line than I need. Basically if the last line starts gets three trigger cells, filled with any data, Add another line, filled with increment formulas based on the previous formulas above each respective cell. Rows also have formatted boarders. New cells in the new row need the same format boarder as the row above. Form will have a minimum of fixed 10 rows. Could have up to another 100 conditional rows of variable length This would save on paper when the list is printed. Need help please. MRGCAV