473,473 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Insert a line in Excel using a Macro

1 New Member
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
1 4267
if1467
25 New Member
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

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

Similar topics

8
by: Vanessa | last post by:
Hi In my VB Dot Net program, I'm using Automation to call Excel worksheet to do some insert some data. I have rename my worksheet to a name. eg. "ABC". How do I insert the worksheet name &...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
2
by: Mansi | last post by:
I'm trying to automate excel from c#. One of the things I need to do is to copy/paste/insert rows in excel via c# code. I tried to do the following: 1) Select a row in excel (a12 to k12) 2)...
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
1
by: kmercer46 | last post by:
Unable to Shift Excel Colums to the Right. Portion of my current VB .NET code is: Dim oXL As Excel.Application Dim oWBook As Excel.Workbook Dim oWSheet As Excel.Worksheet Dim oRng As...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
1
by: ashok0866 | last post by:
I had created a macro to read data from an excel sheet and write the values to a text file. I had used "ActiveSheet.Range("GB" & k).Value" command to read the values from the excel. The issue...
0
by: grego9 | last post by:
I am trying to insert a new blank row above any row in my excel spreadsheet that has the text "NO" in column O. The macro I have written (below) works fine - apart from when there are two or three...
1
MitchR
by: MitchR | last post by:
Good Morning Folks; I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.