PDA

View Full Version : Copy non continuous ranges and paste it new word file



suny100
06-25-2012, 07:34 PM
Hello everybody , I need code to check bulk of data in excel sheet then if this criteria matched (I need to take every group ), it should copy every bulk of(group) data up on this criteria then open new word file and paste them in this file , I try the following code but it gives me just one record in word


Private Sub CommandButton1_Click()
Module1.sort
Dim iRow As Long
Dim appwd As Object
Dim wrdDoc
Dim Count As Integer
Set appwd = CreateObject("Word.Application")
appwd.Visible = True
Set wrdDoc = appwd.Documents.Add
For iRow = 1 To 10000
If Cells(iRow, "E").Value <> Empty And Cells(iRow, "E").Value = Cells(iRow + 1, "E").Value Then
Range(Cells(iRow, 1), Cells(iRow, 10)).Select
Selection.Copy
Range(Cells(iRow + 1, 1), Cells(iRow + 1, 10)).Select
Selection.Copy

appwd.Selection.PasteSpecial Placement:=wdInLine
appwd.Documents.Save

Set appwd = Nothing
End If
Next iRow

End Sub

GTO
06-26-2012, 04:48 AM
Hi Suny,

Admittedly read through quickly, but how about cutting the file down to a sample for the current issue and posting (attaching)? It would seem less easy for us to guess at data layout/type and wanted outcome, than for you to supply said; would not you agree?

Mark