auto fill with specific interval numbers

faizee

Board Regular
Joined
Jan 28, 2009
Messages
214
Office Version
  1. 2016
Platform
  1. Windows
Dear all
i want to fill series with specific intervals
for example

auto fill with 2 intervalauto fill with 3 interval
8585
8585
8685
8686
8786
8786
8887
8887
8987
8988
88
88
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You need to provide us with a bit more information if you want us to tailor a solution to suit your needs.
What does the initial data look like (how to we know what values to do this for, and how do we know what the interval is)?
What range is your data in?
And do you want the solution to happen to the current existing data, or write the results to a new location?
Is a VBA solution acceptable.

It might be helpful to show us BEFORE/AFTER images, so we can see exactly what your data looks like initially.
 
Upvote 0
its a simple query,
I just want to fill cell with number with specific intervals,
like 2 , 3 or 4
column a
11
11
12
12
13
13
14
14


and if interval is 3, then cell auto fill should be
11
11
11
12
12
12
13
13
13

an go on
 
Upvote 0
Try this:
VBA Code:
Sub MyFillMacro()

    Dim i As Integer
    Dim lr As Long
    Dim r As Long
    Dim v As Variant
    Dim x As Long
    
    Application.ScreenUpdating = False
    
'   Prompt for interval
    i = InputBox("What interval do you want?")
    If i <= 1 Then
        MsgBox "You have entered an invalid value", vbOKOnly, "ENTRY ERROR!"
        Exit Sub
    End If
        
'   Find last row with data in column A
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through rows backwards
    For r = lr To 1 Step -1
'       Get current value
        v = Cells(r, "A")
'       Calculate how many rows to insert
        x = i - Application.WorksheetFunction.CountIf(Range("A:A"), v)
'       Insert rows, if necessary and add values
        If x > 0 Then
            Rows(r + 1 & ":" & r + x).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
            Range(Cells(r + 1, "A"), Cells(r + x, "A")) = v
        End If
    Next r

    Application.ScreenUpdating = True

End Sub
 
Upvote 0
not VBA
i want through formula, or auto fill series
 
Upvote 0
not VBA
i want through formula, or auto fill series
I had asked if VBA was an acceptable solution in my first reply, but you did not answer that question.
There were actually a few question in there that you did not answer.

That is the problem if you don't describe exactly what you want in full detail and don't answer all our questions.
We are then left to make assumptions and/or "guesses", which may not actually work for you.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,175
Messages
6,129,312
Members
449,499
Latest member
HockeyBoi

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