paul_0722
08-24-2008, 07:36 PM
I have a spreadsheet with five lines of text:
line 1: TEXT
line 2: TEXT
line 3: TEXT
line 4: TEXT
line 5: TEXT
What I want to achieve with one macro:
line 1: TEXT
line 2: <Blank>
line 3: TEXT
line 4: <Blank>
line 5: TEXT
line 6: <Blank>
line 7: TEXT
line 8: <Blank>
line 9: <Blank>
line 10: TEXT
My code so far is not working - likely because I am missing something about ActiveCell property and activate method. I've tried to comment what I was thinking would happen but it's obviously not.
Any help appreciated.
Option Explicit
Sub test()
''Active Cell is R1,C1
ActiveCell.Offset(1, 0).Activate ''from row 1, move down 1 row to row 2 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.Offset(1, 0).Activate ''from what is now row 3, move down 1 row to row 4 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.Offset(1, 0).Activate ''from what is now row 5, move down 1 row to row 6 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.Offset(1, 0).Activate ''from what is now row 7, move down 1 row to row 8 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.EntireRow.Insert ''insert another row
End Sub
line 1: TEXT
line 2: TEXT
line 3: TEXT
line 4: TEXT
line 5: TEXT
What I want to achieve with one macro:
line 1: TEXT
line 2: <Blank>
line 3: TEXT
line 4: <Blank>
line 5: TEXT
line 6: <Blank>
line 7: TEXT
line 8: <Blank>
line 9: <Blank>
line 10: TEXT
My code so far is not working - likely because I am missing something about ActiveCell property and activate method. I've tried to comment what I was thinking would happen but it's obviously not.
Any help appreciated.
Option Explicit
Sub test()
''Active Cell is R1,C1
ActiveCell.Offset(1, 0).Activate ''from row 1, move down 1 row to row 2 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.Offset(1, 0).Activate ''from what is now row 3, move down 1 row to row 4 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.Offset(1, 0).Activate ''from what is now row 5, move down 1 row to row 6 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.Offset(1, 0).Activate ''from what is now row 7, move down 1 row to row 8 and,
ActiveCell.EntireRow.Insert ''insert row
ActiveCell.EntireRow.Insert ''insert another row
End Sub