View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jesper Kaas Jesper Kaas is offline
external usenet poster
 
Posts: 10
Default VBA Does not recognize cell contents

On Thu, 26 Nov 2020 12:48:26 -0800 (PST), programmernovice
wrote:


Maybe a stupid question, but is the file optvol.xlsx open in Excel
when you test? Pretty sure it has to be for VBA to actually do the
If-test.
--
Jesper Kaas -


Hi, Jesper, it is indeed open. And no, it's not a stupid question!

Can you help me out here? Many thanks for responding.


Try to change: If
Workbooks("optvol.xlsx").Sheets("optvol").Range("A 10") = "put" Then

Range("c4") = "it works"

to:
If Workbooks("optvol.xlsx").Sheets("optvol").Range("A 10") = "put" Then

Activesheet.Range("c4") = "it works"

That works for a simillar test here.

PS: To find out how to perform tasks in Excel via VBA, you can record
a macro while doing the stuff manually in Excel, and the check the
recorded code.

I can recommend John Walkenbach "Power programming with VBA".
--
Jesper Kaas -