Please help; I've tried about 25 versions of different forums' code to insert a line into a table--but no luck yet. I'm just trying to have a macro that goes down a vertical list of dates in a table, starting in cell AS8, and does the following:
First checks to see if the cell to the left (AR8 in this first case) is zero. If so, it goes to the next cell down. If not, it adds blank table rows below the current row (number of rows to add being in AR8). It then moves down to the next row. This loop continues until it hits an empty cell. Here's an example of the what the data in the worksheet looks like:
AR AS
[TABLE="class: cms_table, width: 177"]
<tbody>[TR]
[TD]0[/TD]
[TD]7/5/2013[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]8/4/2013[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]11/30/2013[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]12/1/2013[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]2/28/2014[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]4/1/2013[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]4/1/2013[/TD]
[/TR]
</tbody>[/TABLE]
And here's my best attempt so far at the code:
Sub FillinLines()
Do
If ActiveCell.Offset(0, -1) = 0 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Select
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell.Offset(0, 0))
End Sub
Any help would be very appreciated!
-Nate
First checks to see if the cell to the left (AR8 in this first case) is zero. If so, it goes to the next cell down. If not, it adds blank table rows below the current row (number of rows to add being in AR8). It then moves down to the next row. This loop continues until it hits an empty cell. Here's an example of the what the data in the worksheet looks like:
AR AS
[TABLE="class: cms_table, width: 177"]
<tbody>[TR]
[TD]0[/TD]
[TD]7/5/2013[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]8/4/2013[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]11/30/2013[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]12/1/2013[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]2/28/2014[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]4/1/2013[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]4/1/2013[/TD]
[/TR]
</tbody>[/TABLE]
And here's my best attempt so far at the code:
Sub FillinLines()
Do
If ActiveCell.Offset(0, -1) = 0 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Select
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell.Offset(0, 0))
End Sub
Any help would be very appreciated!
-Nate