Many urgent excel at vertical instead of horizontal word

k0st4din

New member
Joined
Aug 7, 2012
Messages
6
Reaction score
0
Points
0
Location
BG, London
Hello to all the great minds of VBA.
Is there someone who can make a macro to copy excel written down in box A: A word document again vertically A1, A2, A3, etc.
Or because this macro works very well, but if you can touch anywhere hirizontalno instead, carry information vertically - >>> this would be the best option.
Thanks in advance



Code:
Sub AutoFillWordTables() 

Dim C As Long 
Dim FileFilter As String 
Dim LastCol As Long 
Dim R As Long 
Dim Rng As Excel.Range 
Dim WordFile As String 
Dim wdApp As Object 
Dim wdDoc As Object 
Dim wdTbl As Object 
Dim Wks As Worksheet 

Set Wks = Worksheets("Sheet1") Set Rng = Wks.Range("A1:A6") 

LastCol = Wks.Cells(Rng.Row, Columns.Count).End(xlToLeft).Column 
Set Rng = Rng.Resize(ColumnSize:=LastCol) 

FileFilter = "Word Documents(*.doc),*.doc, All Files(*.*),*.*" 
WordFile = Excel.Application.GetOpenFilename(FileFilter) 

If WordFile = "False" Then Exit Sub 

Set wdApp = CreateObject("Word.Application") 
Set wdDoc = wdApp.Documents.Open(WordFile) 

For C = 1 To LastCol 
    Set wdTbl = wdDoc.Tables(C) 
    For R = 1 To Rng.Rows.Count 
        wdTbl.Range.Cells(R).Range.Text = Rng.Cells(R, C) 
    Next R 
Next C 

wdApp.Visible = True 

Set wdApp = Nothing 
Set wdDoc = Nothing 
Set wdTbl = Nothing 

End Sub
 
Back
Top