Add More Rows

arnapsui

Board Regular
Joined
Mar 16, 2010
Messages
55
Hi

I have an employee list with Employee ID in Column-A starting from A3onwards. A2 has the Field Name "Employee ID".

Now, I want to have VBA coding to add number of rows to be added under each employee number where the number of rows are entered in A1 and to be filled with the Emplyee ID till the row above where the second employee ID starts. This should be same for all employee ID in that list.

Can anyone help me to do this?

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Can you provide a sample, it will explain it more.
 
Upvote 0
Column A
A1 - To enter number for number of rows
A2 - Filed Name "Employee Code"
A3 till A100 for example have employee codes (lets assume that A2 has the code 1111 and A2 has 2222 and A3 has 5765 so on till A100)

I want 30 rows, for instance, from A2 till A32 which filled with 1111. Then, from A33 till A63 filled with 2222 so on.

I hope this will make you to get a picture of the question. I have no idea how to submit an excel sheet in this forum.

Please get back to me if you have any questions and Can you help me to submit my excel sheet in this forum?

Thanks your consideration.
 
Upvote 0
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG17Jul56
[COLOR="Navy"]Dim[/COLOR] Lst [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] RwNum [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
RwNum = Range("A1")
Lst = Range("A" & Rows.Count).End(xlUp).Row
[COLOR="Navy"]For[/COLOR] Rw = Lst To 3 [COLOR="Navy"]Step[/COLOR] -1
    [COLOR="Navy"]With[/COLOR] Range("A" & Rw)
       .EntireRow.Resize(RwNum - 1).Insert
       .Offset(-RwNum + 1).Resize(RwNum) = .Value
    [COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] Rw
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top