0

here is what i want:

Assume I have 2 ranges of data A and B. B is calculated from a series of calculation included values of range A. I want a loop of 20 times to put B into A and calculate B again. How do I do this?

Thanks in advance

0

1 Answer 1

1

Here is a very simple VBA loop that creates a 20 x 20 matrix. It will help you understand looping with two number ranges.

Sub looptutorial() Dim a As Integer, b As Integer ThisWorkbook.ActiveSheet.Select For b = 1 To 20 For a = 1 To 20 Cells(a, b).Select Selection.FormulaR1C1 = a * b Next a Next b End Sub 
Sign up to request clarification or add additional context in comments.

2 Comments

'Select' should be avoided in VBA.
@brettdj yes thanks for the comment. I wanted to make it intuitive how the code worked when the op stepped through the code. I agree with you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.