Im trying to write a VBA code where it will copy and paste data from an excel sheet to a powerpoint table. Pasting data over to powerpoint table is fine. The issue is that I can't solve is I' trying to paste one cell at a time in each column(L6, M6 N6), and then move over to the next row and repeat(L7, M7, N7)
So for example, the first value to copy will be in Cell "L6." After L6 is copied, it'll copy M6, N6, O6, P6 etc etc. Once I'm done with Row 6 it should start over again at L7, M7, N7 O7, P7. etc.
I think nested loop is the answer, but I do not really know how to use it (the below eample is wrong I know.
Here's my attempt so far:
so to explain
this is what I want to happen if I were to code it line by line
etc
So for example, the first value to copy will be in Cell "L6." After L6 is copied, it'll copy M6, N6, O6, P6 etc etc. Once I'm done with Row 6 it should start over again at L7, M7, N7 O7, P7. etc.
I think nested loop is the answer, but I do not really know how to use it (the below eample is wrong I know.
Here's my attempt so far:
Code:
j = 0
With ppslide.Shapes("table1")
For k = 0 To 4
For i = 1 To 5
.Select
.Table.Cell(3, i).Shape.TextFrame.TextRange.Text = Format(ThisWorkbook.Sheets("ws").Range("L6").Offset(k, j).Value, "0.00"
j = j + 1
Next i
j = 0
j = j + 1
Next k
End With
End If
this is what I want to happen if I were to code it line by line
Code:
table.cell(3,1) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(0,0).value, "0.00")
table.cell(3,2) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(0,1).value, "0.00")
table.cell(3,3) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(0,2).value, "0.00")
table.cell(3,4) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(0,3).value, "0.00")
table.cell(3,5) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(0,4).value, "0.00")
table.cell(4,1) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(1,0).value, "0.00")
table.cell(4,2) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(1,1).value, "0.00")
table.cell(4,3) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(1,2).value, "0.00")
table.cell(4,4) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(1,3).value, "0.00")
table.cell(4,5) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(1,4).value, "0.00")
table.cell(5,1) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(2,0).value, "0.00")
table.cell(5,2) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(2,1).value, "0.00")
table.cell(5,3) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(2,2).value, "0.00")
table.cell(5,4) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(2,3).value, "0.00")
table.cell(5,5) = Format(Thisworkbook.sheets("ws").Range("L6").Offset(2,4).value, "0.00")
etc