Alter this code to make it loop through rows and columns

oliviar

Board Regular
Joined
Sep 12, 2010
Messages
184
Hello my friends!
I have created this code which turns a range expressed between col A and B - into a list in column F.
So is the start of the range is 10 in A1, and the end of the range is 15 in B1, then f1 is 10, f2 is 11, f3 is 12, f4 is 13, etc.

However my code is static, and will only make the column in F and will only look at the numbers in A1 and B1. But I have more ranges to split up, in A2&B2 and A3&B3, and so on.

How can my code loop through all the ranges expressed between Col A and B on rows 2 and below, and put them into columns after F until exhausted? :confused:

Code:
Sub dotest()
Range("f1").Select

Range("f1") = Range("b1")
  ActiveCell.Offset(1, 0).Select
If Range("b1") > Range("a1") Then
Do
        ActiveCell.Value = ActiveCell.Offset(-1, 0).Value - 1
        ActiveCell.Offset(1, 0).Select
    Loop Until ActiveCell.Offset(-1, 0) - Range("a1").Value = 0
    End If
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
big rainband crossing the city. out to about caulfield by the look
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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