View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Help with named-cell referencing

Hi,

Am Tue, 24 Nov 2020 11:54:10 -0800 (PST) schrieb programmernovice:

I have two open workbooks:

SPX-BS.xlsm and

Book1.xlsm

There is a cell named "premium" in SPX-BS which I need to access from a macro to post the value to Book1. If I enter manually

'SPX-BS.xlsm'!premium into a cell on Book1 it works fine. However if, within a macro I type

Range("A7") = 'SPX-BS.xlsm'!premium

I get an "Compile Error Syntax Error" message.


try:
Range("A7") = Workbooks("SPX-BS.xlsm").Sheets("Sheet1").Range("premium")

Modify the sheet name as expected.


Regards
Claus B.
--
Windows10
Office 2016