PDA

View Full Version : Specific task: Insert rows into existing table


Pajoooo
Nov 12, 2009, 01:23 PM
Specific task. See Attachment.

Thanks!

Pajoooo
Nov 12, 2009, 02:11 PM
NO other spreadsheets. FIGURE 1 reprsent table before inserting rows and FIGURE 2 after that.

JBeaucaire
Nov 12, 2009, 06:01 PM
Pajoo, your needs are not clear. There is no explanation of why the values in Figure 2 were inserted.

If this is just a random process, it will be manual.

Also, your use of merged cells for each row not only makes no sense (you can use a single row and simply expand the row height to attain the exact same appearance) but your use of merged cells will interfere with any macro-type assistance we try to offer.

VBA and merged cells do not play nicely with each other. Plus, as I've already said, your table layout gains nothing from the merged cells. The same layout can be attained without them.

Pajoooo
Nov 13, 2009, 12:47 PM
Error. See below.

Pajoooo
Nov 13, 2009, 12:49 PM
Why the values in Figure 2 were inserted?

Figure 1 is part of larger project that has predefined tables with predefined numbers of rows. Sometimes, really sometimes, table need additional rows and red bordered method (attachment) is acceptable for me.

Forget merged cells.

Thanks!

JBeaucaire
Nov 13, 2009, 03:08 PM
The red bordered method is not an explained method. It's just a table of letters that don't match anything you've shown in table 1 or table 2.

I can't remember the last time I had this much trouble understanding what someone was trying to do. Sorry, it must be me.

Pajoooo
Nov 13, 2009, 04:03 PM
NO, it surely me.Try this one.

JBeaucaire
Nov 14, 2009, 11:00 AM
Maybe this:

Option Explicit

Sub InsertRows()
'JBeaucaire (11/14/2009)
Dim Cnt As Long

Cnt = Application.WorksheetFunction.CountA(Range("N5:N14"))

If Cnt = 0 Then Exit Sub

Range("A13:K" & 12 + Cnt).Insert Shift:=xlDown
Range("N5:N" & 4 + Cnt).Copy Range("F13")
Range("N5:N14").ClearContents

End Sub

Pajoooo
Nov 15, 2009, 12:34 PM
All work fine, but...

Print layout after added rows is not same. How erase number of added rows below double red line.
If I insert, for example, 5 rows, same number of rows (5) I need to erase below double red line.

Thanks!

JBeaucaire
Nov 16, 2009, 12:02 AM
I can't see how this sample sheet and question relates the to the prior question in any way.

Perhaps this completely different need deserves a thread of its own, it's clear you're starting completely over from what we did above.