ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy each data record of a name list and place it under the onecopied (https://www.excelbanter.com/excel-programming/434647-copy-each-data-record-name-list-place-under-onecopied.html)

andreashermle

Copy each data record of a name list and place it under the onecopied
 
Dear Experts:

I got a name list on a worksheet with the following columns

SURNAME NAME CITY
Smith John New York City
Wilber Joe Denver
Garden Thomas San Diego


This list has for example twenty rows / data records. For certain
reasons the following action should be excecuted automatically (using
VBA) on my list regardless of the number of rows:

Duplicate each row and place it directly under the one copied. The
result would then look like this:

SURNAME NAME CITY
Smith John New York City
Smith John New York City
Wilber Joe Denver
Wilber Joe Denver
Garden Thomas San Diego
Garden Thomas San Diego

Help is much appreciated.

Thank you very much in advance. Regards, Andreas

Don Guillett

Copy each data record of a name list and place it under the one copied
 
Sub copyeachrow()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
Rows(i).Copy
Rows(i + 1).Insert
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"andreashermle" wrote in message
...
Dear Experts:

I got a name list on a worksheet with the following columns

SURNAME NAME CITY
Smith John New York City
Wilber Joe Denver
Garden Thomas San Diego


This list has for example twenty rows / data records. For certain
reasons the following action should be excecuted automatically (using
VBA) on my list regardless of the number of rows:

Duplicate each row and place it directly under the one copied. The
result would then look like this:

SURNAME NAME CITY
Smith John New York City
Smith John New York City
Wilber Joe Denver
Wilber Joe Denver
Garden Thomas San Diego
Garden Thomas San Diego

Help is much appreciated.

Thank you very much in advance. Regards, Andreas



andreas-hermle

Copy each data record of a name list and place it under the onecopied
 
On 7 Okt., 15:47, "Don Guillett" wrote:
Sub copyeachrow()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
Rows(i).Copy
Rows(i + 1).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"andreashermle" wrote in message

...



Dear Experts:


I got a name list on a worksheet with the following columns


SURNAME * NAME * *CITY
Smith * * * * * John * * * New York City
Wilber * * * * *Joe * * * * Denver
Garden * * * * Thomas * San Diego


This list has for example twenty rows / data records. For certain
reasons the following action should be excecuted automatically (using
VBA) *on my list regardless of the number of rows:


Duplicate each row and place it directly under the one copied. The
result would then look like this:


SURNAME * NAME * * *CITY
Smith * * * * * John * * * * New York City
Smith * * * * * John * * * * New York City
Wilber * * * * *Joe * * * * * Denver
Wilber * * * * *Joe * * * * * Denver
Garden * * * * Thomas * *San Diego
Garden * * * * Thomas * *San Diego


Help is much appreciated.


Thank you very much in advance. Regards, Andreas- Zitierten Text ausblenden -


- Zitierten Text anzeigen -


Great, it is working. Thank you very much for your professional help.
Regards, Andreas


All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com