VBA - Insert Row if Cell Has Value

Microsoft Microsoft excel 2004 (mac)
January 26, 2010 at 08:09:27
Specs: Macintosh OSX 10.6.2
Hi. I'm completely new to macros, and need to write one to insert two rows beneath the cell being checked if the cell has a value. So, for example: if A2 contains data, add 2 rows below it. I need this function to work on all cells in that row, so that when I add a new line of data, two extra blank rows will be automatically added below it. Is this possible?

See More: VBA - Insert Row if Cell Has Value

Report •


#1
January 26, 2010 at 08:43:43
re: I need this function to work on all cells in that row, so that when I add a new line of data, two extra blank rows will be automatically added below it.

You want it to work on all cells in what row?

Your example used Row 2, but the line I quoted above says "...when I add a new line of data...".

Are you saying that whenever you add a new line of data, you want to insert 2 blank rows below it? Wouldn't a "new line" already have blank rows below it?

Please explain further.


Report •

#2
January 26, 2010 at 08:57:46
Sorry, perhaps I didn't make myself clear.

This is for my shop's product database. The worksheet that I want this function to apply to is filled with functions which feed the information through from another - main - worksheet in the book. In the main worksheet, my products have one row per product, with all the information being transferred by formulas into the subsidiary worksheet. However, on the subsidiary sheet, I need to have three rows for each product. Therefore, I need the macro, if possible, to add in the two extra blank rows beneath each data filled row on the subsidiary sheet.

The upshot would be that as I enter a new product on the main sheet, it would appear on the subsidiary sheet with two additonal rows beneath it. I hope this makes things clearer.


Report •

Related Solutions


Ask Question