Second appeal for help

A

Angol

I need to perform an operation on several long series of data. It works
fine on an single data set.

And I'm able to generate the thousand or so sets of addresses -
F3:F252,C3:C252,AM41, etc. that I need. Unsurprisingly, though,
VBA/Excel protests that if I copy a thousand lines like that into a
macro I get a procedure that is is too large.

The elegant way to do what I want is to instruct Excel to perform the
regression, and then move one line down in a lookup table to change the
references and then run it again.

Long ago I recorded macros in Lotus123 that would pick up an
instruction to go, e.g. 1 line down and repeat something we'd done
before and I vaguely understand what the structure of what I need would
look like.

Can anyone advise me as to what I should be doing?

PS. This repeats an earlier appeal for help that sadly went unanswered.
The operation I'm performing is
Application.Run "ATPVBAEN.XLA!Regress", ActiveSheet.Range("F2:F251"),
ActiveSheet.Range("C2:C251"), False, False, ,
ActiveSheet.Range("AM21"), False, False, False, False, , False.
 
D

dominicb

Good evening Angol

Can you select the range(s) that need to be worked on? If so, use
for next loop thus:

For Each Rnge in Selection

' Your code goes here, but replace the cell address with Rnge

Next Rnge

When the range(s) is / are selected, this code will perform any give
operation on each selected cell in turn.

HTH

Dominic
 
A

Angol

Many thanks DominicB for your help. I've just got back to the problem
and have been reading up on For-Next Loops. Despite much experimenting
I've still not managed to write what I need.
I need the macro to execute Application.Run "ATPVBAEN.XLA!Regress",
ActiveSheet.Range("F2:F251"), ActiveSheet.Range("C2:C251"), False,
False, , ActiveSheet.Range("AM21"), False, False, False, False, ,
False.
and then do the same thing on Ranges F3:F252, C3:C252 and AM41 and so
on, i.e. to pick data from ranges each of which is one line below its
predecessor and to print the results to cells 20 lines apart. (What
happens after that to tidy up the results, produce graphs, etc., works
fine)
I need to do this about a thousand times on each set of data.
While I can see the general idea For-Next-Step 1 and For-Next-Step 20,
writing what's needed is beyond me.
Can DominicB or anyone else help?
 

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