Loop until a certain row

geoffcraver

New Member
Joined
Aug 14, 2008
Messages
8
Hello,

I'm looking to perform a calculation on some data from subtotals. Because of the format the last value isn't in column A and there are spaces in the data. Below is my code:

Cells(1, 23).Value = "Unused Lines"

'calculates the unused lines
x = 2

Do While Cells(1, x).Value <> ""


Cells(x, 23).Value = "=IF(ISNUMBER(SEARCH(""Total"",RC[-21])),(1-RC[-1]/RC[-2]),IF(ISNUMBER(SEARCH(""total"",RC[-20])),(1-RC[-1]/RC[-2]),IF(ISNUMBER(SEARCH(""Total"",RC[-18])),(1-RC[-1]/RC[-2]),IF(ISNUMBER(SEARCH(""total"",RC[-17])),(1-RC[-1]/RC[-2]),""""))))"


x = x + 1

Loop



How should I change the do while loop to a loop that runs until row 30,000?

Thanks

Mike
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello,

I'm looking to perform a calculation on some data from subtotals. Because of the format the last value isn't in column A and there are spaces in the data. Below is my code:

Cells(1, 23).Value = "Unused Lines"

'calculates the unused lines
x = 2

Do Until ws.Range("A1").Row.Number = 30000


Cells(x, 23).Value = "=IF(ISNUMBER(SEARCH(""Total"",RC[-21])),(1-RC[-1]/RC[-2]),IF(ISNUMBER(SEARCH(""total"",RC[-20])),(1-RC[-1]/RC[-2]),IF(ISNUMBER(SEARCH(""Total"",RC[-18])),(1-RC[-1]/RC[-2]),IF(ISNUMBER(SEARCH(""total"",RC[-17])),(1-RC[-1]/RC[-2]),""""))))"


x = x + 1

Loop



How should I change the do while loop to a loop that runs until row 30,000?

Thanks

Mike

I think that's it.
 
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