zielonapani
New Member
- Joined
- Sep 5, 2013
- Messages
- 38
Hi,
I am trying to write a code for Powerpoint Macro that will open excel file, copy a range based on the month(so variable range) and copy in the live link into the specific slide.
I think I am pretty close to succed that but i got stuck on the "variable range"
Could you please have a look what I am doing wrong?
Thank you
I am trying to write a code for Powerpoint Macro that will open excel file, copy a range based on the month(so variable range) and copy in the live link into the specific slide.
I think I am pretty close to succed that but i got stuck on the "variable range"
Could you please have a look what I am doing wrong?
Thank you
Code:
Private Sub ExcelImportData()
Dim xlApp As Object
Dim xlWorkBook As Object
Set xlApp = CreateObject("Excel.Application")
Set xlWorkBook = xlApp.Workbooks.Open("\\ukcomaunas01\P2.Order Acquisition\05 Departmental\06 Proposals & Estimating\2017\01 Staff Meeting\CurrentYear\MASTER Quotes by month.xlsx", True, False)
xlApp.Visible = True
Dim Y, Y1 As Date
Dim m1 As String
Y = DateSerial(Year(Now), Month(Now), 0)
m1 = MonthName(Month(Y))
Y1 = Format(Y, "yyyy")
Dim R1 As String
Dim C1 As String
Dim R2 As String
Dim C2 As String
Dim T As String
Dim O As Long
Dim TT As String
Dim TTT As Range
Dim rFind As Range
Dim rng As Range
With xlWorkBook.sheets("2017").Range("A2:AV2")
Set rFind = .Find(What:=m1, LookAt:=xlWhole, LookIn:=xlValues, MatchCase:=False, SearchFormat:=False)
End With
R1 = rFind.Row
C1 = rFind.Column
R2 = rFind.Row + 38
C2 = rFind.Column + 8
T = rFind.Address
[COLOR=#ff0000]TT = Chr(34) & rFind.Address & ":" & xlWorkBook.sheets("2017").Cells(rFind.Row + 7, rFind.Column + 38) & Chr(34)
Set rng = xlWorkBook.sheets("2017").Range(TT)[/COLOR]
rng.Copy
Dim ppt As Presentation
Dim shape As shape
[COLOR=#ff0000]
ActivePresentation.Slides(3).Shapes.PasteSpecial(Link:=True).Select[/COLOR]
Set xlApp = Nothing
Set xlWorkBook = Nothing
End Sub