By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,377 Members | 3,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,377 IT Pros & Developers. It's quick & easy.

Insert a line in Excel using a Macro

P: 1
I have an Excel spreadsheet where all data resides in column A.

Cell A1 is blank and the data follows after that. I need to insert a line after each line with the ChangeType: add. How can I do this with macro?


dn: CN=
changetype: add
title:
telephoneNumber:
displayName:
mail:

dn: CN=
changetype: add
title:
telephoneNumber:
displayName:
mail:
Apr 8 '08 #1
Share this Question
Share on Google+
1 Reply


P: 25
I have an Excel spreadsheet where all data resides in column A.

Cell A1 is blank and the data follows after that. I need to insert a line after each line with the ChangeType: add. How can I do this with macro?


dn: CN=
changetype: add
title:
telephoneNumber:
displayName:
mail:

dn: CN=
changetype: add
title:
telephoneNumber:
displayName:
mail:
Try this:

Expand|Select|Wrap|Line Numbers
  1. Sub Insert_Row()
  2.  
  3. Dim rownum As Integer
  4. Dim Currcell As Range
  5.  
  6. rownum = 4
  7. Set Currcell = ActiveSheet.Cells(rownum, 1)
  8. Do While Currcell <> ""
  9.     Currcell.insert Shift:=xlDown
  10.     rownum = rownum + 8
  11.     Set Currcell = ActiveSheet.Cells(rownum, 1)
  12. Loop
  13. End Sub
Apr 8 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.