[TABLE="width: 69"]
<tbody>[TR]
[TD]columnA
aaa[/TD]
[TD="align: right"]columnB
1[/TD]
[/TR]
[TR]
[TD]bbb[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]ccc[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]ddd[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]eee[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]fgh[/TD]
[TD="align: right"]2[/TD]
[/TR]
</tbody>[/TABLE]
Hi there, am trying to write a code so rows are ( or not ) inserted depending on the value of the cell.
If cell value is 0 or 1, there shoulb be zero row inserted.
if cell value is 2 or greater, there should be 2 or more rows inserted.
Rows need to be inserted down.
Below is the code I have started to write but as I am new with VBA I am really struggling, does anybody knows how to write it properly? Many thanks
Sub jasmine()
Application.ScreenUpdating = False
Dim irow As Integer, lastrow As Integer
For irow = 1 To lastrow
If IsEmpty (Range("B" & irow))
Shift.xlDown
Else: ActiveCell.EntireRow.Resize(rowsize:=ActiveCell.Value).Insert Shift:=xlDown
End If
Columns("b").ClearContents
Application.ScreenUpdating = True
End Sub
<tbody>[TR]
[TD]columnA
aaa[/TD]
[TD="align: right"]columnB
1[/TD]
[/TR]
[TR]
[TD]bbb[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]ccc[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]ddd[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]eee[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]fgh[/TD]
[TD="align: right"]2[/TD]
[/TR]
</tbody>[/TABLE]
Hi there, am trying to write a code so rows are ( or not ) inserted depending on the value of the cell.
If cell value is 0 or 1, there shoulb be zero row inserted.
if cell value is 2 or greater, there should be 2 or more rows inserted.
Rows need to be inserted down.
Below is the code I have started to write but as I am new with VBA I am really struggling, does anybody knows how to write it properly? Many thanks
Sub jasmine()
Application.ScreenUpdating = False
Dim irow As Integer, lastrow As Integer
For irow = 1 To lastrow
If IsEmpty (Range("B" & irow))
Shift.xlDown
Else: ActiveCell.EntireRow.Resize(rowsize:=ActiveCell.Value).Insert Shift:=xlDown
End If
Columns("b").ClearContents
Application.ScreenUpdating = True
End Sub