Hi,
I am trying to reference a sheet by name in a UDF but do not know the syntax.
Whithout the variable the reference is:
Workbooks("Salaries").Worksheets("Accounting").Range("j3").Value
And that, of course works.
I tried:
Workbooks("Salaries").Worksheets(sheetname).Range("j3").Value
Where sheetname is a String variable containing the value Accounting
And no dice.
I have seen examples where variables are used, but it is usually an Integer referenceing the number of the worksheet ei. isheet
What is the syntax in VBA to reference the sheet by name (not number) using a variable?
Thank you.
I am trying to reference a sheet by name in a UDF but do not know the syntax.
Whithout the variable the reference is:
Workbooks("Salaries").Worksheets("Accounting").Range("j3").Value
And that, of course works.
I tried:
Workbooks("Salaries").Worksheets(sheetname).Range("j3").Value
Where sheetname is a String variable containing the value Accounting
And no dice.
I have seen examples where variables are used, but it is usually an Integer referenceing the number of the worksheet ei. isheet
What is the syntax in VBA to reference the sheet by name (not number) using a variable?
Thank you.