How to make a sequence of one number increment from one by one across a range.

roudarreza

New Member
Joined
Jun 7, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello,

I hope everyone is doing great!

I would like to know if there is a way (function, macro, etc.) to make a sequence of one number (in this case the number is in cell B1=22.5) increment from one by one across a range (from cell A1 to A9).

Thank you for reading and your time.

AB
1322.5
23
33
43
52.5
62
72
82
92
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Welcome to the Board!

Unfortunately, your question, in conjunction with the data you show, makes no sense to me.
Can you explain in more detail? Walk us through this example, step-by-step, explaining exactly how you get those values.
 
Upvote 0
1686158832363.png

Thank you so much for your swiftly reply, Joe4. For more context this is related to a baseball scenario/problem:

1. Value in E3 is the total batters faced by the opposing pitcher. That number could be anything. Value in E4 is just the sum of those values (B3:D11) so I can compare that both number match.
2. What I am trying to know is if there is a way to divide such number by each plate appearance by batter (it cannot be greater than one but sometimes it could be less than one).
3. The image above shows the sequence. In baseball there is a sequence from number batter one to batter number nine which cannot be changed. Once batter nine consumes their plate appearance the count starts again.

1686159467518.png

4. The second image shows the aggregate of those plate appearances which is why I intended to obtain at the end.

Thank you so much, if anything else is needed, like a file or link to the actual doc, please let me know.
 
Upvote 0
I am a big baseball fan myself.
But how can a pitcher face a partial/fractional batter?

So, are you looking to populate a grid like in your first image (columns B-D), or like your second (aggregate in a single column)?
 
Upvote 0
Oh, nice! I hope you are a not an A´s fan though, they are having an awful season.

A pitcher facing a partial batter has to do with an average problem. A pitcher could face 17 batters in one game, 25 in another, so in a sample of 5 games if a pitcher has faced 15, 17, 17, 22 and 25 batters the average is 19.2. But you are right I did not think about that so probably the best would be to just round to the closer number.

About you second question - and to be honest I just would like to make it work - it does not matter if it is like in the first or second image. Of course the second image would be for me more convenient but whatever works best.

TIA.
 
Upvote 0
No, I am a Blue Jays fan. It is sad what has happened to the A's. They use to be a good franchise.

Are you open to a VBA solution?
There may be a way to do it with a formula, but I am afraid it is beyond my formula prowess.
 
Upvote 0
Oh, I see, a Blue Jays fan, nice, it is tough division to win, same for a wildcard. Anyway. Yes I am open to a VBA solution, whatever it takes. I want to reiterate my gratitude for your help.
 
Upvote 0
OK, see if this helps you. I made some minor modifications to your structure. This is what I have initially:
1686174091395.png


I put the total we want to get to in cell E1. I increased the number of columns in case it is more than that.

Then, I created this VBA code:
VBA Code:
Sub PopulateGrid()

    Dim c As Long
    Dim r As Long
    Dim tot As Double
    
    Application.ScreenUpdating = False
    
'   Set initial column to start in (col B = 2)
    c = 2
    
'   Get total from cell E1
    tot = Range("E1").Value
    
'   Loop through columns
    Do
'       Loop through rows 3-11
        For r = 3 To 11
'           Check to see if running total > 1
            If tot > 0 Then
'               Check to see if value left>=1
                If tot > 1 Then
                    Cells(r, c).Value = 1
                Else
                    Cells(r, c).Value = tot
                    Exit Do
                End If
'           Decrement tot
            tot = tot - 1
            Else
                Exit Do
            End If
        Next r
'       Increment to next column
        c = c + 1
    Loop
    
    Application.ScreenUpdating = True
    
End Sub

When you run it on the data grid I show above, this is what the result looks like:
1686174179773.png


Hopefully, that gives you what you are looking for. Tweaks can be made to the code, as needed.
 
Upvote 0
Here's a way to do it with a formula. Any fractional amount is ignored.

Book1
ABCDE
121.85
2a3
3b3
4c3
5d2
6e2
7f2
8g2
9h2
10i2
Sheet3
Cell Formulas
RangeFormula
B2:B10B2=LET(q,INT(E1/9),q+((SEQUENCE(9)<=E1-9*q)))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,216,144
Messages
6,129,120
Members
449,488
Latest member
qh017

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