I have a spreadsheet with several hundred files, each has n number of images in it. What I need to do is insert a row for every image, below the original file. So I put the number of rows to insert into the main row, and would like to use that as the reference value.
Like this:
[TABLE="class: outer_border, width: 500, align: center"]
<tbody>[TR]
[TD][/TD]
[TD][TABLE="width: 89"]
<tbody>[TR="class: outer_border"]
[TD="width: 89"]image names[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: outer_border"]
[TD="width: 64"]# images[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]IE[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]Representation[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]File[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 89"]
<tbody>[TR="class: outer_border"]
[TD="width: 89"]H002.tif[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: outer_border"]
[TD="width: 64, align: right"]10[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]IE[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]Representation[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]File[/TD]
[TD][TABLE="width: 89"]
<tbody>[TR="class: outer_border"]
[TD="width: 89"]H003.tif[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: outer_border"]
[TD="width: 64, align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I found someone else had something like this but I think it's meant for rows that are one after the other, not with the two empty rows in-between. It will insert the first set of rows but then doesn't continue for the next value. Also, I think it's set up to include the existing row in the count. So, would it be possible to set it to insert 10 rows, then skip 2, read the next value, etc.?
The code I found:
Hopefully I explained this well, sorry it's so much.
Like this:
[TABLE="class: outer_border, width: 500, align: center"]
<tbody>[TR]
[TD][/TD]
[TD][TABLE="width: 89"]
<tbody>[TR="class: outer_border"]
[TD="width: 89"]image names[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: outer_border"]
[TD="width: 64"]# images[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]IE[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]Representation[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]File[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 89"]
<tbody>[TR="class: outer_border"]
[TD="width: 89"]H002.tif[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: outer_border"]
[TD="width: 64, align: right"]10[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]IE[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 104"]
<tbody>[TR="class: outer_border"]
[TD="width: 104"]Representation[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]File[/TD]
[TD][TABLE="width: 89"]
<tbody>[TR="class: outer_border"]
[TD="width: 89"]H003.tif[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: outer_border"]
[TD="width: 64, align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I found someone else had something like this but I think it's meant for rows that are one after the other, not with the two empty rows in-between. It will insert the first set of rows but then doesn't continue for the next value. Also, I think it's set up to include the existing row in the count. So, would it be possible to set it to insert 10 rows, then skip 2, read the next value, etc.?
The code I found:
Code:
[COLOR=#333333]Sub AddColumns()[/COLOR]
[COLOR=#333333]Dim i As Integer, n As Integer, m As Long, currentCell As Range[/COLOR]
[COLOR=#333333]Set currentCell = ActiveCell[/COLOR]
[COLOR=#333333]Do While Not IsEmpty(currentCell)[/COLOR]
[COLOR=#333333]n = currentCell.Value - 1[/COLOR]
[COLOR=#333333]m = currentCell.Row[/COLOR]
[COLOR=#333333]If n > 0 Then[/COLOR]
[COLOR=#333333]Rows(m + 1 & ":" & m + n).Insert[/COLOR]
[COLOR=#333333]Set currentCell = currentCell.Offset(n + 1, 0)[/COLOR]
[COLOR=#333333]Else[/COLOR]
[COLOR=#333333]Set currentCell = currentCell.Offset(1, 0)[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]Loop[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
Hopefully I explained this well, sorry it's so much.