Moving chart window in macro

  • Thread starter Thread starter Rustar
  • Start date Start date
R

Rustar

Does anyone out there know how to move the chart window
range in a macro? I'm backtesting stock data on an
indicator I'm building, and I'd like to be able to inch
forward a day at a time.
I wrote a macro a couple of years ago that did this, but
for the life of me, I can't get anything to work now.
From what I remember, it was just a small snippet of code
(maybe 5-6 lines) and i used the activecell and offset
functions to change the range. If anyone knows how to do
this, I'd be incredibly grateful, maybe even to the point
of considering them a minor god. The ability to move both
sides of the window (1-50, then 2-51, etc.) would be
cool, but not necessary.

Thanks, Rustar
 
Rustar,

I am taking a shot in the dark here.

I think your critical functions are offset and resize. In VBA, offset
doesn't work the same as it does in the normal spreadsheet mode. You must
use resize as you move along.

Borrowing from XL Help:

This example assumes that Sheet1 contains a table that has a header row. The
example selects the table, without selecting the header row. The active cell
must be somewhere in the table before the example is run.

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, _
tbl.Columns.Count).SelectSo you could just increment your offset
position?Hope this is of some value.Regards,Kevin
 
Rustar -

I've written an article for TechTrax e-zine which shows how to do this
in a worksheet without VBA, just using scroll bars and dynamic range
names. It will be published on the web in a week or so. Here's the
link to the current issue, from which you'll be able to find the new one
when it comes out.

- Jon
 
Back
Top