Incremental numbers in one cell || Office 2016

arjun5ne

New Member
Joined
Jul 24, 2023
Messages
4
Office Version
  1. 2013
  2. 2011
Platform
  1. Windows
Dear Team,

I need help on excel formula how to display incremental numbers in one cell.

Example: 7 increment i.e. 7 14 21 28 35 42 49 56 63 70 - - - - - -

but in one cell display till 49 number only i.e. i need to use CONCATENATE till 49
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
please find image for reference
 

Attachments

  • image.jpg
    image.jpg
    129.3 KB · Views: 13
Upvote 0
There may be native Excel functions that can achieve this (I'm unaware of any) but if you're willing to entertain a UDF, the following should give you what you want. When you enter the Steps() formula, enter the <start number> or select a cell containing the value, <upper limit> or select a cell containing the value, <step> or select a cell containing the value. So using your sample data, and this code:
VBA Code:
Function Steps(StartNo As Long, EndNo As Long, Jump As Long) As String
    Dim x As Long, s As String
    Do While x <= EndNo - Jump
        If s = "" Then
            s = StartNo
            x = StartNo
        Else
            x = x + Jump
            s = s & " " & x
        End If
    Loop
    Steps = s
End Function

Produces this result:
Cell Formulas
RangeFormula
F2:F3F2=Steps(7,D2,7)
 
Upvote 0
Hi Kevin thanks for your response.

Can we not do this without VBA code in excel 2016
 
Upvote 0
Concatenation of a range of cells in Excel 2016 and before is limited. You could use UDFs, like the one suggested, or power query. If you are looking for a native formula that does not require you to reference each cell in your range one by one, I believe you are out of luck. I'm going to assume you're not looking for a wall of text like
Excel Formula:
=CONCATENATE(IF($B$2<=$D2,$B$2&" ",""),IF($B$3<=$D2,$B$3&" ",""),IF($B$4<=$D2,$B$4&" ",""),IF($B$5<=$D2,$B$5&" ",""),IF($B$6<=$D2,$B$6&" ",""),IF($B$7<=$D2,$B$7&" ",""),IF($B$8<=$D2,$B$8&" ",""),IF($B$9<=$D2,$B$9&" ",""),IF($B$10<=$D2,$B$10&" ",""),IF($B$11<=$D2,$B$11&" ",""),IF($B$12<=$D2,$B$12&" ",""),IF($B$13<=$D2,$B$13&" ",""),IF($B$14<=$D2,$B$14&" ",""),IF($B$15<=$D2,$B$15&" ",""),IF($B$16<=$D2,$B$16&" ",""),IF($B$17<=$D2,$B$17&" ",""),IF($B$18<=$D2,$B$18&" ",""),IF($B$19<=$D2,$B$19&" ",""),IF($B$20<=$D2,$B$20&" ",""),IF($B$21<=$D2,$B$21&" ",""),IF($B$22<=$D2,$B$22&" ",""),IF($B$23<=$D2,$B$23&" ",""),IF($B$24<=$D2,$B$24&" ",""),IF($B$25<=$D2,$B$25&" ",""),IF($B$26<=$D2,$B$26&" ",""),IF($B$27<=$D2,$B$27&" ",""),IF($B$28<=$D2,$B$28&" ",""),IF($B$29<=$D2,$B$29&" ",""),IF($B$30<=$D2,$B$30&" ",""),IF($B$31<=$D2,$B$31&" ",""),IF($B$32<=$D2,$B$32&" ",""))
 
Upvote 0
Upvote 0
VBA Code:
Function Steps(StartNo As Long, EndNo As Long, Jump As Long) As String
    Dim x As Long, s As String
    Do While x <= EndNo - Jump
        If s = "" Then
            s = StartNo
            x = StartNo
        Else
            x = x + Jump
            s = s & " " & x
        End If
    Loop
    Steps = s
End Function
A little more compact...
VBA Code:
Function Steps(StartNo As Long, EndNo As Long, Jump As Long) As String
  Dim X As Long, S As String
  For X = StartNo To EndNo Step Jump
    S = S & " " & X
  Next
  Steps = Trim(S)
End Function
 
Upvote 0
You're welcome. Hope you got something that was useful. :)

BTW, what is the issue regarding versions?

Also BTW, another UDF option

VBA Code:
Function Steps(StartNo As Long, EndNo As Long, Jump As Long) As String
  Steps = Join(Filter(Application.Transpose(Evaluate(Replace(Replace("if(mod(row(#:^)-#," & Jump & ")=0,row(#:^),""x"")", "#", StartNo), "^", EndNo))), "x", False))
End Function
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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