How to insert the entire containing columns in word document

  • Part of the code from the entire codes that copy the value of the cell in column B that in my case is B1 into word document is limited for what I need.


    What I need from the code below is to how to change B1 to the entire column of B to based in the bookmark (Revenue1) in word document instead of B1 only. Any code that can be added to B1 to make the code works? I tried to change that range from ("B1:B") but not work as well.


    Any Help please?


    Code
        With objWord.ActiveDocument
            .Bookmarks("Revenue1").Range.Text = ws.Range("B1").Value
    
        End With
  • Try this, but you probably only need the cells that have been used.


    Code
    With objWord.ActiveDocument
     .Bookmarks("Revenue1").Range.Text = ws.Range("B:B").Value
     End With

    This will only copy the used cells

    Code
    With objWord.ActiveDocument
     .Bookmarks("Revenue1").Range.Text = ws.Range(ws.Cells(1, 2), ws.Cells(wsrows.Count, 2).End(xlUp)).Value
     End With

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!