VBA Solution to insert number of rows based on condition

Chengo

Board Regular
Joined
Mar 14, 2012
Messages
50
Hi there,

I am trying to figure out an elegant VBA method to insert certain number of rows with added data based on conditions identified in different sheet.

Data Sheet:
Type
Country
Id
Deadline
House
Austria
123456
01/01/2018
Flat
Germany
234567
02/02/2018
Shed
Poland
543212
03/03/2018
House
Finland
568445
02/02/2018
Flat
Spain
958476
01/01/2018
Shed
France
476940
04/04/2018

<tbody>
</tbody>

Requirement Sheet:
House
Weeks
Flat
Weeks
Shed
Weeks
Task1
-6
Task1
-4
Task1
-4
Task2
-5
Task2
-3
Task2
-3
Task3
-3
Task3
0Task3
0
Task4
-3
Task4
1
Task4
1
Task5
-1
Task5
2
Task6
0
Task7
1
Task8
3
Task9
4
Task10
4

<tbody>
</tbody>

Task List Sheet
Type
Country
Id
Deadline
Task Name
Task Date
House
Austria
123456
01/01/2018
Task1
20/11/2017
House
Austria
123456
01/01/2018
Task2
27/11/2017
House
Austria
123456
01/01/2018
Task3
11/12/2017
House
Austria
123456
01/01/2018
Task4
11/12/2017
House
Austria
123456
01/01/2018
Task5
25/12/2017
House
Austria
123456
01/01/2018
Task6
01/01/2018
House
Austria
123456
01/01/2018
Task7
08/01/2018
House
Austria
123456
01/01/2018
Task8
22/01/2018
House
Austria
123456
01/01/2018
Task9
29/01/2018
House
Austria
123456
01/01/2018
Task10
29/01/2018

<tbody>
</tbody>


Essentially I want to accomplish the following:
1. Evaluate row on Data sheet.
2. Compare Type value in row, then look up that type on Requirements sheet and identify the number of tasks
3. Insert the number of rows into Task List sheet by copying all the cells in that row
4. Append Task Name and Task Date at the end of each row.
Task Date is the number of work weeks before (negative) or after (positive) the Deadline.
5. Return to Data sheet and perform same exercise with next row etc.

Example:
House has 10 tasks so Task List sheet should have 10 rows for each respective row from Data sheet that has House specified.

Any ideas anyone?

Thanks in advance!
 
Last edited:
Glad to help & thanks for the feedback
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,216,045
Messages
6,128,480
Members
449,455
Latest member
jesski

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