0

I had code in Excel VBA that I want to convert to run in Powerpoint VBA as well. here is what I have so far in ppt VBA:

Dim wbkISS As Excel.Workbook
Dim varSheetISS As Excel.Worksheet

Set wbkISS = Workbooks.Open(FileName:="C:\Users\...\Documents\ISS.xlsm")
Set varSheetISS = wbkISS.Worksheets("For ISS")

strIDRangeISS = "A2:D50"

varSheetISS = varSheetISS.Range(strIDRangeISS)

For iRowISS = LBound(varSheetISS, 1) To UBound(varSheetISS, 1)
    ...
    For iRowFCST = LBound(varSheetFCST, 1) To UBound(varSheetFCST, 1)
        ...

But at "LBound(varsheetISS" it gives me the Compile error: Expected Array. My code works fine in Excel so I'm thinking I have the wrong syntax for ppt?

3
  • This code suffers from no 'Option Explicit' Header. Commented Aug 2, 2017 at 16:55
  • That really works fine in Excel? Pretty sure it does not... If you want to run that in PPT you will first need to create an Excel Application object Commented Aug 2, 2017 at 17:52
  • Sorry the excel vba version is different, the code I posted there is what I modified so far for ppt Commented Aug 2, 2017 at 18:13

1 Answer 1

1

Had to post as answer:

This code suffers from no 'Option Explicit' Header.

The variable varSheetISS is being passed around recklessly.

It start life life as a worksheet, then is cast to a range(where the intention was to get the Range's Value).

A lot of this can be avoided by using Option Explicit.

Dim issArray As Variant: issArray = varSheetISS.Range(strIDRangeISS).Value2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.