Consulting

Results 1 to 2 of 2

Thread: COPY CERTAIN COLUMN IF ROW CONTAINS CERTAIN DATA FROM EXCEL TO WORD

  1. #1

    COPY CERTAIN COLUMN IF ROW CONTAINS CERTAIN DATA FROM EXCEL TO WORD

    Help Please,

    Hello there. i am trying to copy columns a,k,l and m column, if there is data in column m, with following code, however i cant do as t copy whole column from a to m.

    Code is

    Sub ExcelWord()


    Dim wdApp As Object
    Dim wd As Object
    Dim c As Range


    On Error Resume Next
    Set wdApp = GetObject(, "Word.Application")
    Set Source = ActiveWorkbook.Worksheets("Sheet1")
    If Err.Number <> 0 Then
    Set wdApp = CreateObject("Word.Application")
    End If
    On Error GoTo 0


    Set wd = wdApp.Documents.Add


    wdApp.Visible = True
    For Each c In Source.Range("m4:m1000") ' Do 1000 rows
    If c > 1 Then
    Source.Range(Cells(c.Row, 1), Cells(c.Row, 14)).Copy
    wdApp.Selection.PasteExcelTable False, False, False
    End If


    Next c
    End Sub

  2. #2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •