Ich hab folgenden VBA Code um Daten von Excel in Word auszugeben, das funktioniert einwandfrei. Nun möchte ich den aber so abändern das er mir nur die Zellen M7, N24 und P7, Q24 und S7, T24 in Word ausgibt. Was muss ich da abändern?
Private Sub CommandButton1_Click()
Dim WordObj As Object
Dim Bereich As Variant
Dim WordDoc As Object
Dim ExTab As Object
Dim i As Integer
Dim x As Integer
Dim y As Integer
Dim arrWks()
Dim iCounter As Integer, iCount As Integer
For iCounter = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(iCounter) Then
Worksheets(ListBox1.List(iCounter)).Activate
End If
Next iCounter
i = ActiveSheet.UsedRange.Rows.Count + 1
Bereich = Range("A6:C" & i).Value
On Error Resume Next
Set WordObj = GetObject(, "word.application.10")
If Err.Number = 429 Then
Set WordObj = CreateObject("word.application.10")
Err.Number = 0
End If
WordObj.Visible = True
Set WordDoc = WordObj.Documents.Add
Set ExTab = WordDoc.Tables.Add _
(WordObj.Selection.Range, UBound(Bereich, 1), UBound(Bereich, 2))
With ExTab
For x = 1 To UBound(Bereich, 1)
For y = 1 To UBound(Bereich, 2)
.Cell(x, y).Range.InsertAfter Bereich(x, y)
Next y
Next x
End With
Set WordObj = Nothing
Set WordDoc = Nothing
Set ExTab = Nothing
End Sub
Besten Dank zum vorausGruss
Roger