Do loop countdown

bahllr

Board Regular
Joined
May 7, 2009
Messages
62
I am trying to do a 'countdown' for the number of items in a list in VBA. I use (cell DA4), the below counta formula and would like the do loop under that to move down one cell (offset formula) and put in the formula (cell above -1). I want this loop to end when the activecells value = 2.

ActiveCell.FormulaR1C1 = "=COUNTA(RC[-103]:R[13]C[-103])+1"
Do Until ActiveCell.Value = 2
ActiveCell.Offset(1, 0) = "=R[-1]C-1"
Loop

Unfortunately, it isn't acting like I thought it would. Any ideas why?

Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Could you post some sample data?

What do you mean by a 'countdown'?

Do you just want to number the items in the list?

Or are you trying to do some sort of count of them?
 
Upvote 0
Norie,

Sorry for the confusion. I have a matrix that I have counted the rows (the matrix is dynamic).

The counta formula that counts the rows is found in cell DA4. If the current cell value is 15, I want the cell below it to be 15-1 or 14. The cell below that 14-1 or 13.

I want this loop to stop when the value of the current cell is equal to 2.

I thought the following code would do this but it isn't looping through the cells as I thought it would.

Do Until ActiveCell.Value = 2
ActiveCell.Offset(1, 0) = "=R[-1]C-1"
Loop
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top