LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Insert Multiple rows with data

I have a quick question.

I have been trying to copy data from one worksheet and inserting it
into another. if I just want to paste it into the other then it will
work, but if I have the code insert rows first then it fails.

The following is my code:

Dim x As String
Range("A2").Select
Do While ActiveCell.Value < ""
Dim nDataRange As Range
Dim InsQuan As Long

x = ActiveCell.Value
Sheets("Sheet1").Select
Set nDataRange = Nothing
Range("J1").Select
Do While ActiveCell.Value < ""
If ActiveCell.Value = x Then
InsQuan = InsQuan + 1
If nDataRange Is Nothing Then
Set nDataRange = ActiveCell
Else
Set nDataRange = Union(nDataRange, ActiveCell)
End If
End If
ActiveCell.Offset(1, 0).Select
Loop
'nDataRange.EntireRow.Select
nDataRange.EntireRow.Copy
Sheets("Sheet4").Select

ActiveCell.Offset(1, 0).Select
ActiveCell.Insert shift:=xlDown
ActiveSheet.Paste
' ActiveCell.Offset(1, 0).Range("A1:A" & InsQuan).Select
'Selection.Insert Shift:=xlDown
''ActiveCell.Select


''ActiveCell.Offset(1, 0).Insert shift:=xlDown
''ActiveCell.Insert shift:=xlDown
''ActiveCell.Offset(1, 0).Select
''Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
'' False, Transpose:=False
''Selection.Insert shift:=xlDown

'ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select
Loop

'ActiveCell.Offset(1, 0).Select

So basically what my code is doing is selecting a name from the target
worksheet and then looping through the worksheet with the data, then
it is trying to insert rows just under the search criteria in the
target page. From here I would like it to insert the data without
deleting all of the other data.

As you can tell by my commit outs of vb code. I have tried several
options

Will someone please assist me

Thank you for all of your help
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert multiple rows sdg8481 Excel Discussion (Misc queries) 4 April 15th 08 07:38 AM
how do insert multiple rows in between multiple lines Ernie Excel Discussion (Misc queries) 1 January 15th 07 10:55 PM
Insert Multiple Rows ucf1020 Excel Discussion (Misc queries) 3 November 1st 05 01:49 PM
how do I insert multiple rows in excel after every row of data grantm5 Excel Discussion (Misc queries) 1 December 14th 04 08:09 PM
Insert multiple rows E. Edgington Excel Programming 2 May 27th 04 09:22 PM


All times are GMT +1. The time now is 08:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"