nugol
03-30-2016, 03:15 AM
Hy folks,
kind of specific but I try my best. Thing is i have a column where in the first 30 rows there is data, then a summary, a break and then there is the same again.
Example:
ColumnA
Data1
Data2
Data3
...
Summary
emptyrow
Data5
Data6
...
Summary
Now I try to tell excel to add a certain amount of rows to the first paragraph (cellswithcriteria) and then some rows to the next paragraph.
That is my code so far.
Dim cellswithcirteria As Variant
Dim cellswithoutcriteria As Variant
cellswithcirteria = Range("D2").Value
cellswithoutcriteria = Range("E2").Value
Range("A1").Select
Selection.End(xlDown).Select
Rows("6:6").Select 'here it should add as many rows as the cellswithcriteria value is
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Rows("15:15").Select 'here it should add as many rows as the cellswithcriteria value is
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Any ideas?
kind of specific but I try my best. Thing is i have a column where in the first 30 rows there is data, then a summary, a break and then there is the same again.
Example:
ColumnA
Data1
Data2
Data3
...
Summary
emptyrow
Data5
Data6
...
Summary
Now I try to tell excel to add a certain amount of rows to the first paragraph (cellswithcriteria) and then some rows to the next paragraph.
That is my code so far.
Dim cellswithcirteria As Variant
Dim cellswithoutcriteria As Variant
cellswithcirteria = Range("D2").Value
cellswithoutcriteria = Range("E2").Value
Range("A1").Select
Selection.End(xlDown).Select
Rows("6:6").Select 'here it should add as many rows as the cellswithcriteria value is
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Rows("15:15").Select 'here it should add as many rows as the cellswithcriteria value is
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Any ideas?