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
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