Help: I need a macro to add words every 3 lines

M

Mirandolle

Hello,

I understand nothing to macro but I am sure that a macro can resolve my
problem.

I have the following columns, for example (it is for a dictionary database):

House
Maison
[empty line]
Car
Voiture
[empty line]
Dog
Chien
[empty line]
etc.....

The first word is always in English and the second is always french.
There is only 1 column but many lines. I would like to add "\en" in
front of each English word, and "\fr" in front of each French word (in
the same cell - I do not want to add a colum)... as a result I should get :

\en House
\fr Maison

\en Car
\fr Voiture

\en Dog
\fr Chien

etc.....

Could someone give me a macro for that ?

hum.. if I do not abuse :-/ ... which macro would do this (if I want to
add another line:)


\en House
\nnoun
\fr Maison

\en Car
\noun
\fr Voiture

\en Dog
\noun
\fr Chien

etc...

A big THANKS! for any help! :)

Miradonlle
 
G

Guest

Hi Mirandolle,

You dont need to use macro for your problem,assuming your data is in column
"A" what you can do is just tag the adjacent colum "B" :

\en
\fr
Blank

and copy the tag till the last row of colum A

In colum "C" use the concencate formula and that will give you your data.

then just copy and past special values Colum C to colum A and yr data is
ready.

To add one more row can be done by adding number is adjesent row and then
sorting and then again updating the sequence number bt adding a text with a
multiple of 3

for example 3A,6A,7A
 
M

Mirandolle

Hi Hitesh,

Thank you very much for your answer !! :)

But, I am not sure to understand you... Point by point:

1- the English and French words are already entered... so I have a VERY
looong list... to add a column with :
\en
\fr
Blank
\en
\fr
Blank

etc.... will be quite long (no ?)

2- I want the tags to be in front of the words. If I add \en and \fr
tags to column B (on the right side of A column), I will get something
like :

house \en
maison \fr
blank

Isn't it ? (\en and \fr should be at the start of each line)

Sorry for all these questions, but I am really bad at Excel... :-(

Hi Mirandolle,

You dont need to use macro for your problem,assuming your data is in column
"A" what you can do is just tag the adjacent colum "B" :

\en
\fr
Blank

and copy the tag till the last row of colum A

In colum "C" use the concencate formula and that will give you your data.

then just copy and past special values Colum C to colum A and yr data is
ready.

To add one more row can be done by adding number is adjesent row and then
sorting and then again updating the sequence number bt adding a text with a
multiple of 3

for example 3A,6A,7A

:

Hello,

I understand nothing to macro but I am sure that a macro can resolve my
problem.

I have the following columns, for example (it is for a dictionary database):

House
Maison
[empty line]
Car
Voiture
[empty line]
Dog
Chien
[empty line]
etc.....

The first word is always in English and the second is always french.
There is only 1 column but many lines. I would like to add "\en" in
front of each English word, and "\fr" in front of each French word (in
the same cell - I do not want to add a colum)... as a result I should get :

\en House
\fr Maison

\en Car
\fr Voiture

\en Dog
\fr Chien

etc.....

Could someone give me a macro for that ?

hum.. if I do not abuse :-/ ... which macro would do this (if I want to
add another line:)


\en House
\nnoun
\fr Maison

\en Car
\noun
\fr Voiture

\en Dog
\noun
\fr Chien

etc...

A big THANKS! for any help! :)

Miradonlle
 
L

L. Howard Kittle

Hi Mirandolle,

I believe Hitesh's solution will work, but you may not fully understand what
he was trying to tell you.

Try this macro. It assumes you data is in column A.

Sub AddToIt()
Dim i As Long
Range("A1").Select

i = Range("A65000").End(xlUp).Row

For i = 1 To i
If ActiveCell.Value <> "" Then
ActiveCell.Value = "\en " & ActiveCell.Value
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "\fr " & ActiveCell.Value
ActiveCell.Offset(1, 0).Select
ElseIf ActiveCell.Value = "" Then
Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Select
If ActiveCell.Value = "" Then
Exit Sub
End If
End If
Next
End Sub

HTH
Regards,
Howard
 
D

Dave Peterson

#1. Type in one group of 3 values (\en, \fr, (blank)), then select all three
and drag it down the column by using the autofill button in the bottom right
corner of that selection. (It won't take too long.)

#2. After you have your new data in column B, insert a new column C:
put this in the top 3 cells:
=b1&" "&a1
=b2&" "&a2
(leave blank)

And drag down the column like you did for column B.

#3. Select column C
Edit|copy
edit|paste special|values

Delete columns A:B (if it worked ok)


Hi Hitesh,

Thank you very much for your answer !! :)

But, I am not sure to understand you... Point by point:

1- the English and French words are already entered... so I have a VERY
looong list... to add a column with :
\en
\fr
Blank
\en
\fr
Blank

etc.... will be quite long (no ?)

2- I want the tags to be in front of the words. If I add \en and \fr
tags to column B (on the right side of A column), I will get something
like :

house \en
maison \fr
blank

Isn't it ? (\en and \fr should be at the start of each line)

Sorry for all these questions, but I am really bad at Excel... :-(
Hi Mirandolle,

You dont need to use macro for your problem,assuming your data is in column
"A" what you can do is just tag the adjacent colum "B" :

\en
\fr
Blank

and copy the tag till the last row of colum A

In colum "C" use the concencate formula and that will give you your data.

then just copy and past special values Colum C to colum A and yr data is
ready.

To add one more row can be done by adding number is adjesent row and then
sorting and then again updating the sequence number bt adding a text with a
multiple of 3

for example 3A,6A,7A

:

Hello,

I understand nothing to macro but I am sure that a macro can resolve my
problem.

I have the following columns, for example (it is for a dictionary database):

House
Maison
[empty line]
Car
Voiture
[empty line]
Dog
Chien
[empty line]
etc.....

The first word is always in English and the second is always french.
There is only 1 column but many lines. I would like to add "\en" in
front of each English word, and "\fr" in front of each French word (in
the same cell - I do not want to add a colum)... as a result I should get :

\en House
\fr Maison

\en Car
\fr Voiture

\en Dog
\fr Chien

etc.....

Could someone give me a macro for that ?

hum.. if I do not abuse :-/ ... which macro would do this (if I want to
add another line:)


\en House
\nnoun
\fr Maison

\en Car
\noun
\fr Voiture

\en Dog
\noun
\fr Chien

etc...

A big THANKS! for any help! :)

Miradonlle
 
M

Mirandolle

Thank you very much Dave ! I am going to try immediately.

In fact, the result I would like to get is a little bit complicated, so
I made two short sample excel files to show what I need to do.

Here, the list I have at the begining:
http://cjoint.com/?igppXa1zeI

And here the result I try to reach:
http://cjoint.com/?igpqw3BNgn

So at the begining I have a long list without space in A column:
[English Word]
[French Word]
[English Word]
[French Word]
[English Word]
[French Word]
etc.

And I try 1- to add a marker in front of each word (for my database and
to export the list); 2- to add an empty line between each couple of
word; 3- to add another line between [English word] and [French Word],
just to indicate the vocabular category. So the result is (markers are
in column A, words are in Column B):

\lx [English Word]
\ps "Names of flowers"
\gn [French Word]

\lx [English Word]
\ps "Names of flowers"
\gn [French Word]

\lx [English Word]
\ps "Names of flowers"
\gn [French Word]

etc.

Well, but may be there is no need to use a macro for all the operation
(I can move easily the words definition from column A to B, etc.), so I
am trying right now the tips you showed me. Thank you again !

Dave said:
#1. Type in one group of 3 values (\en, \fr, (blank)), then select all three
and drag it down the column by using the autofill button in the bottom right
corner of that selection. (It won't take too long.)

#2. After you have your new data in column B, insert a new column C:
put this in the top 3 cells:
=b1&" "&a1
=b2&" "&a2
(leave blank)

And drag down the column like you did for column B.

#3. Select column C
Edit|copy
edit|paste special|values

Delete columns A:B (if it worked ok)


Hi Hitesh,

Thank you very much for your answer !! :)

But, I am not sure to understand you... Point by point:

1- the English and French words are already entered... so I have a VERY
looong list... to add a column with :
\en
\fr
Blank
\en
\fr
Blank

etc.... will be quite long (no ?)

2- I want the tags to be in front of the words. If I add \en and \fr
tags to column B (on the right side of A column), I will get something
like :

house \en
maison \fr
blank

Isn't it ? (\en and \fr should be at the start of each line)

Sorry for all these questions, but I am really bad at Excel... :-(
Hi Mirandolle,

You dont need to use macro for your problem,assuming your data is in column
"A" what you can do is just tag the adjacent colum "B" :

\en
\fr
Blank

and copy the tag till the last row of colum A

In colum "C" use the concencate formula and that will give you your data.

then just copy and past special values Colum C to colum A and yr data is
ready.

To add one more row can be done by adding number is adjesent row and then
sorting and then again updating the sequence number bt adding a text with a
multiple of 3

for example 3A,6A,7A

:



Hello,

I understand nothing to macro but I am sure that a macro can resolve my
problem.

I have the following columns, for example (it is for a dictionary database):

House
Maison
[empty line]
Car
Voiture
[empty line]
Dog
Chien
[empty line]
etc.....

The first word is always in English and the second is always french.
There is only 1 column but many lines. I would like to add "\en" in
front of each English word, and "\fr" in front of each French word (in
the same cell - I do not want to add a colum)... as a result I should get :

\en House
\fr Maison

\en Car
\fr Voiture

\en Dog
\fr Chien

etc.....

Could someone give me a macro for that ?

hum.. if I do not abuse :-/ ... which macro would do this (if I want to
add another line:)


\en House
\nnoun
\fr Maison

\en Car
\noun
\fr Voiture

\en Dog
\noun
\fr Chien

etc...

A big THANKS! for any help! :)

Miradonlle
 
M

Mirandolle

L. Howard Kittle said:
I believe Hitesh's solution will work, but you may not fully understand what
he was trying to tell you.
You're right, and I am sorry! I cannot catch the point because I never
use Excel :-( I have a lot experience with Word, but I never use macro.
Try this macro. It assumes you data is in column A.
Yes wonderful ! It makes the biggest part of the work! Thank you so much!

I found another Macro to add a blank line beetween each couple of word.
The Macro is:

Sub ajoutdeligne()
Dim i As Long, x As Long, lr As Long
x = ActiveSheet.UsedRange.Rows.Count
lr = ActiveCell.SpecialCells(xlLastCell).Row
If 3 > lr Then Exit Sub
If lr / 2 = Int(lr / 2) Then lr = lr + 1
For i = lr To 3 Step -2
Rows(i).EntireRow.Insert
Next i
End Sub

With your macro and this macro, I can get this:

\en [english word]
\fr [french word]
[emplty line]
\en [english word]
\fr [french word]
[empty]
\en [english word]
\fr [french word]
etc...

The last point: If I want to add a line BETWEEN "\en [english word]" AND
"\fr [french word]", how to do ? (I want to add the same line each
time: "\cat common name") I would like to get:

\en [english word]
\cat Common name
\fr [french word]
[emplty line]
\en [english word]
\ps Common name
\fr [french word]
[empty]
\en [english word]
\ps Common name
\fr [french word]
etc.

You can have a look to the result I am trying to get here:
http://cjoint.com/?igpqw3BNgn

\en \fr or \lx \ps, etc. are just marker, I can change them myself.
Next, it is not important if markers and words are all in column A (or
separated in A and B), because I will export the file onto a new text
format (database file), so it's even better to keep all in one column.
Your macro do a great job!

Dave's tip is working to, to I keep on making a few tests... Thank you
very much for your kind help !

Sub AddToIt()
Dim i As Long
Range("A1").Select

i = Range("A65000").End(xlUp).Row

For i = 1 To i
If ActiveCell.Value <> "" Then
ActiveCell.Value = "\en " & ActiveCell.Value
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "\fr " & ActiveCell.Value
ActiveCell.Offset(1, 0).Select
ElseIf ActiveCell.Value = "" Then
Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Select
If ActiveCell.Value = "" Then
Exit Sub
End If
End If
Next
End Sub

HTH
Regards,
Howard

Hello,

I understand nothing to macro but I am sure that a macro can resolve my
problem.

I have the following columns, for example (it is for a dictionary
database):

House
Maison
[empty line]
Car
Voiture
[empty line]
Dog
Chien
[empty line]
etc.....

The first word is always in English and the second is always french. There
is only 1 column but many lines. I would like to add "\en" in front of
each English word, and "\fr" in front of each French word (in the same
cell - I do not want to add a colum)... as a result I should get :

\en House
\fr Maison

\en Car
\fr Voiture

\en Dog
\fr Chien

etc.....

Could someone give me a macro for that ?

hum.. if I do not abuse :-/ ... which macro would do this (if I want to
add another line:)


\en House
\nnoun
\fr Maison

\en Car
\noun
\fr Voiture

\en Dog
\noun
\fr Chien

etc...

A big THANKS! for any help! :)

Miradonlle
 
D

Dave Peterson

I don't open attachments or links. (lots of people won't.)

If you don't get a volunteer to look at your files, you may want to repost in
plain text.
Thank you very much Dave ! I am going to try immediately.

In fact, the result I would like to get is a little bit complicated, so
I made two short sample excel files to show what I need to do.

Here, the list I have at the begining:
http://cjoint.com/?igppXa1zeI

And here the result I try to reach:
http://cjoint.com/?igpqw3BNgn

So at the begining I have a long list without space in A column:
[English Word]
[French Word]
[English Word]
[French Word]
[English Word]
[French Word]
etc.

And I try 1- to add a marker in front of each word (for my database and
to export the list); 2- to add an empty line between each couple of
word; 3- to add another line between [English word] and [French Word],
just to indicate the vocabular category. So the result is (markers are
in column A, words are in Column B):

\lx [English Word]
\ps "Names of flowers"
\gn [French Word]

\lx [English Word]
\ps "Names of flowers"
\gn [French Word]

\lx [English Word]
\ps "Names of flowers"
\gn [French Word]

etc.

Well, but may be there is no need to use a macro for all the operation
(I can move easily the words definition from column A to B, etc.), so I
am trying right now the tips you showed me. Thank you again !

Dave said:
#1. Type in one group of 3 values (\en, \fr, (blank)), then select all three
and drag it down the column by using the autofill button in the bottom right
corner of that selection. (It won't take too long.)

#2. After you have your new data in column B, insert a new column C:
put this in the top 3 cells:
=b1&" "&a1
=b2&" "&a2
(leave blank)

And drag down the column like you did for column B.

#3. Select column C
Edit|copy
edit|paste special|values

Delete columns A:B (if it worked ok)


Hi Hitesh,

Thank you very much for your answer !! :)

But, I am not sure to understand you... Point by point:

1- the English and French words are already entered... so I have a VERY
looong list... to add a column with :

\en
\fr
Blank

\en
\fr
Blank

etc.... will be quite long (no ?)

2- I want the tags to be in front of the words. If I add \en and \fr
tags to column B (on the right side of A column), I will get something
like :

house \en
maison \fr
blank

Isn't it ? (\en and \fr should be at the start of each line)

Sorry for all these questions, but I am really bad at Excel... :-(

HITESH wrote:

Hi Mirandolle,

You dont need to use macro for your problem,assuming your data is in column
"A" what you can do is just tag the adjacent colum "B" :

\en
\fr
Blank

and copy the tag till the last row of colum A

In colum "C" use the concencate formula and that will give you your data.

then just copy and past special values Colum C to colum A and yr data is
ready.

To add one more row can be done by adding number is adjesent row and then
sorting and then again updating the sequence number bt adding a text with a
multiple of 3

for example 3A,6A,7A

:



Hello,

I understand nothing to macro but I am sure that a macro can resolve my
problem.

I have the following columns, for example (it is for a dictionary database):

House
Maison
[empty line]
Car
Voiture
[empty line]
Dog
Chien
[empty line]
etc.....

The first word is always in English and the second is always french.
There is only 1 column but many lines. I would like to add "\en" in
front of each English word, and "\fr" in front of each French word (in
the same cell - I do not want to add a colum)... as a result I should get :

\en House
\fr Maison

\en Car
\fr Voiture

\en Dog
\fr Chien

etc.....

Could someone give me a macro for that ?

hum.. if I do not abuse :-/ ... which macro would do this (if I want to
add another line:)


\en House
\nnoun
\fr Maison

\en Car
\noun
\fr Voiture

\en Dog
\noun
\fr Chien

etc...

A big THANKS! for any help! :)

Miradonlle
 
M

Mirandolle

Dave said:
I don't open attachments or links. (lots of people won't.)
:-o ! Sorry, I didn't know... It's just a site to store attachment like
sometimes people store picture on ImageShack or similar services.
It links to an empty web page (with no advertising nor popup) with a
auto-link to donwload the file I uploaded.
If you don't get a volunteer to look at your files, you may want to repost in
plain text.
Fortunately, Someone sent me a macro and it is doing the job quite well.
So I am very happy and I can save many hours of work! :)

But thank you very much for your help, I appreciate a lot! :)

Mordicus

PS: Here is the macro someone made for me:

Sub phase2()

Application.ScreenUpdating = False
Columns(1).Insert
[b65536].End(xlUp).Offset(1, -1).Select

Do While ActiveCell.Row >= 2
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\gn"
ActiveCell.EntireRow.Insert
ActiveCell = "\ps"
ActiveCell.Offset(0, 1) = "Name of Flowers"
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\lx"
ActiveCell.EntireRow.Insert

Loop
Application.ScreenUpdating = True
End Sub
 
M

Mirandolle

I forgot to say:

The macro is doign a good job but I get the marker (\lx, \ps, etc.) and
the words in two column, A and B.

If there is a tweak to put the markers and the words in the same column
A, juste separate by a space, for example:
\lx_tulip
\ps_name of flowers
\gn_tulipe

" _ " is for a blank space

.... then it would be perfect ! If anyone knows how to tweak the macro, I
am very interested ! :)


Dave said:
I don't open attachments or links. (lots of people won't.)

:-o ! Sorry, I didn't know... It's just a site to store attachment like
sometimes people store picture on ImageShack or similar services.
It links to an empty web page (with no advertising nor popup) with a
auto-link to donwload the file I uploaded.
If you don't get a volunteer to look at your files, you may want to
repost in
plain text.

Fortunately, Someone sent me a macro and it is doing the job quite well.
So I am very happy and I can save many hours of work! :)

But thank you very much for your help, I appreciate a lot! :)

Mordicus

PS: Here is the macro someone made for me:

Sub phase2()

Application.ScreenUpdating = False
Columns(1).Insert
[b65536].End(xlUp).Offset(1, -1).Select

Do While ActiveCell.Row >= 2
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\gn"
ActiveCell.EntireRow.Insert
ActiveCell = "\ps"
ActiveCell.Offset(0, 1) = "Name of Flowers"
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\lx"
ActiveCell.EntireRow.Insert

Loop
Application.ScreenUpdating = True
End Sub
 
D

Dave Peterson

This inserts a new column B and puts the strings there.

After you verify that it's correct, just delete column A.

Option Explicit
Sub testme01()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim oRow As Long

With ActiveSheet
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

oRow = FirstRow
.Columns(2).Insert

For iRow = FirstRow To LastRow Step 2
.Cells(oRow, "B").Value = "\lx " & .Cells(iRow, "A").Value
oRow = oRow + 1
.Cells(oRow, "B").Value = "\ps name of flowers"
oRow = oRow + 1
.Cells(oRow, "B").Value = "\gn " & .Cells(iRow + 1, "A").Value
oRow = oRow + 2
Next iRow
End With

End Sub

(I should have read you earlier message better. It looks like you explained it
in plain text. But when I saw the files, I just ignored the rest.)


I forgot to say:

The macro is doign a good job but I get the marker (\lx, \ps, etc.) and
the words in two column, A and B.

If there is a tweak to put the markers and the words in the same column
A, juste separate by a space, for example:
\lx_tulip
\ps_name of flowers
\gn_tulipe

" _ " is for a blank space

... then it would be perfect ! If anyone knows how to tweak the macro, I
am very interested ! :)
Dave said:
I don't open attachments or links. (lots of people won't.)

:-o ! Sorry, I didn't know... It's just a site to store attachment like
sometimes people store picture on ImageShack or similar services.
It links to an empty web page (with no advertising nor popup) with a
auto-link to donwload the file I uploaded.
If you don't get a volunteer to look at your files, you may want to
repost in
plain text.

Fortunately, Someone sent me a macro and it is doing the job quite well.
So I am very happy and I can save many hours of work! :)

But thank you very much for your help, I appreciate a lot! :)

Mordicus

PS: Here is the macro someone made for me:

Sub phase2()

Application.ScreenUpdating = False
Columns(1).Insert
[b65536].End(xlUp).Offset(1, -1).Select

Do While ActiveCell.Row >= 2
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\gn"
ActiveCell.EntireRow.Insert
ActiveCell = "\ps"
ActiveCell.Offset(0, 1) = "Name of Flowers"
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\lx"
ActiveCell.EntireRow.Insert

Loop
Application.ScreenUpdating = True
End Sub
 
M

Mirandolle

Hi Dave,

Your macro is great and will do the job very perfectly !

Thank you very much !!!

Dave said:
This inserts a new column B and puts the strings there.

After you verify that it's correct, just delete column A.

Option Explicit
Sub testme01()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim oRow As Long

With ActiveSheet
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

oRow = FirstRow
.Columns(2).Insert

For iRow = FirstRow To LastRow Step 2
.Cells(oRow, "B").Value = "\lx " & .Cells(iRow, "A").Value
oRow = oRow + 1
.Cells(oRow, "B").Value = "\ps name of flowers"
oRow = oRow + 1
.Cells(oRow, "B").Value = "\gn " & .Cells(iRow + 1, "A").Value
oRow = oRow + 2
Next iRow
End With

End Sub

(I should have read you earlier message better. It looks like you explained it
in plain text. But when I saw the files, I just ignored the rest.)


I forgot to say:

The macro is doign a good job but I get the marker (\lx, \ps, etc.) and
the words in two column, A and B.

If there is a tweak to put the markers and the words in the same column
A, juste separate by a space, for example:
\lx_tulip
\ps_name of flowers
\gn_tulipe

" _ " is for a blank space

... then it would be perfect ! If anyone knows how to tweak the macro, I
am very interested ! :)
Dave Peterson wrote:


I don't open attachments or links. (lots of people won't.)

:-o ! Sorry, I didn't know... It's just a site to store attachment like
sometimes people store picture on ImageShack or similar services.
It links to an empty web page (with no advertising nor popup) with a
auto-link to donwload the file I uploaded.


If you don't get a volunteer to look at your files, you may want to
repost in
plain text.

Fortunately, Someone sent me a macro and it is doing the job quite well.
So I am very happy and I can save many hours of work! :)

But thank you very much for your help, I appreciate a lot! :)

Mordicus

PS: Here is the macro someone made for me:

Sub phase2()

Application.ScreenUpdating = False
Columns(1).Insert
[b65536].End(xlUp).Offset(1, -1).Select

Do While ActiveCell.Row >= 2
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\gn"
ActiveCell.EntireRow.Insert
ActiveCell = "\ps"
ActiveCell.Offset(0, 1) = "Name of Flowers"
ActiveCell.Offset(-1, 0).Select
ActiveCell = "\lx"
ActiveCell.EntireRow.Insert

Loop
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top