VBA- add new rows if a condition is met (excel2007)


New Member
Feb 14, 2014
I am new to VBA and I would appreciate any help on this. My question is how can I write a routine to add rows in one Sheet if a condition which involves a different Sheet is met (excel 2007).

In Sheet 1 is a list of ("liquid") names (cells C4:C26) which will need to be expanded should the IF condition be satisfied. In row 27 I have a subtotal (whihc is using data from columns D onwards), and from row 29 down cells are not empty.

The condition I want to verify is in Sheet 4-column I, where it is reported whether a name is classified as "liquid" or "illiquid". If the number of "liquid" names in sheet4-column I is more than the number of names in Sheet1-C4:C26 I would like to add as many rows as the difference between the two lists. Also I would like to make sure that the subtotals that I have in row 27 (and that will be shifted down when new rows are added) will also inlcude the data in the new rows (the subtotal is taking data from columns D onwards).

Should the code need to inlcude the name of the tabs, Sheet 1 is called Summary and Sheet 4 CDS Data

Thank you

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result


Well-known Member
Nov 1, 2008
Why are you double posting this without reacting to the reply in your first post?


Double posting is very impolite. Also if you post the same question on another forum, then please put links in both posts so people can see what has been done and said about the issue. You are asking people's help, time and effort, so please respect that.

Do not reply any further to this thread, please continue in the original thread, link above.

Watch MrExcel Video

Forum statistics

Latest member
Hazem Hassan

This Week's Hot Topics