Hello dear community,
I have VBA code which works perfectly fine for one sheet, I want to modify it to work for each sheet.
If WS range (E69) = "Run VBA" to run VBA + loop , else ignore..
Code is something like this...
Instead of sheet ("DATA") I want to run code for each sheet which in cell E69 is = "Run VBA"
Is it simple or need complex change?
I have VBA code which works perfectly fine for one sheet, I want to modify it to work for each sheet.
If WS range (E69) = "Run VBA" to run VBA + loop , else ignore..
VBA Code:
For Each WS In Worksheets
If (WS.Name) <> "Run VBA" Then
ThisWorkbook.Worksheets(WS.Name).Activate
'Run VBA and loop...'
Code is something like this...
Instead of sheet ("DATA") I want to run code for each sheet which in cell E69 is = "Run VBA"
Is it simple or need complex change?
Code:
Sub XL2()
Dim wkname, pptname, currentPath As String
Application.DisplayAlerts = False
'Other Values
pptname = "Temp.pptx"
currentPath = ThisWorkbook.Path
'Ópening Powerpoint
Set ppApp = CreateObject("Powerpoint.Application")
Set pPres = ppApp.Presentations.Open(currentPath & Application.PathSeparator & pptname, msoFalse, msoCTrue, msoCTrue)
'Opening Excel
Set wk = ThisWorkbook
sldtoDuplicate = 1
Dim myvalues
myvalues = Array("DATA")
For my = LBound(myvalues) To UBound(myvalues)
Set Sh = wk.Worksheets((myvalues(my)))
i = 0
For j = 0 To Sh.ChartObjects.Count
For Each obj In Sh.ChartObjects
' Debug.Print
If obj.TopLeftCell.Column = Sh.Range("F80").Offset(0, i).Column Then
'Duplicate First Slide
Set pattrenSlide = pPres.Slides(sldtoDuplicate)
Set sldrange = pattrenSlide.Duplicate
sldrange.MoveTo (pPres.Slides.Count)
Set sld = pPres.Slides(pPres.Slides.Count)