Evaluate problem

W

Walter Briscoe

This is an excerpt from some working code:
With Workbooks("stations.xls").Sheets("Sheet1")
Here = ActiveWorkbook.Name: .Activate ' See what is going on
StationRow = Application.Match(EndStation, .Range("$A$1:$A$298"), 0)
s = .Cells(StationRow, OfficeHoursCol).Formula
s = Evaluate(GetSub(s, "^=HYPERLINK.(.*), .Hours..$", "$1"))
TxURL s

When I comment the "Here = ..." line, the "s = Evaluate..." does not
work as intended.
When "Sheet1" is active "A40" is a reference to a cell in "Sheet1"; when
inactive, it is a reference to whatever other sheet happens to be
active.

As it happens, the fix was easy. I commented the two "s =" lines, and
inserted
s = "http://www.journeyplanner.org/imr/XSLT_SOI_REQUEST?" & _
"language=en&itdLPxx_agent=ticketOffice&type=stop&id=" & _
.Cells(StationRow, JPcodesCol)

I can probably do better when I think about it. At the moment, I am
happy to have a fix.

I would appreciate light on similar problems. I suspect it is a problem,
already known to gurus here. I have been assuming that the sequence
Here = ActiveWorkbook.Name: .Activate ' See what is going on
<some code>
Windows(Here).Activate

is equivalent to
<some code>
 
S

sali

Walter Briscoe said:
This is an excerpt from some working code:
With Workbooks("stations.xls").Sheets("Sheet1")
Here = ActiveWorkbook.Name: .Activate ' See what is going on

When I comment the "Here = ..." line, the "s = Evaluate..." does not
work as intended.

after 'name' there is a colon ':', is it intentional?
colon ':' is a command separattor, so on that line you have actualy two
commands, '.activate' being the second
it is a bad practice, since program flow is not so clear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top