Trying to modify this 'auto-fill down to the next empty cell' macro to auto-fill sequential numbers instead

funguy

New Member
Joined
Feb 7, 2012
Messages
24
Hi all, I've attached a worksheet with the macro already installed that will auto-fill cell values down through empty cells to the next cell containing data (and so on and so on).. It works great! BUT, I'm now trying to modify it to make it fill empty spaces with sequential numbers. Any help would be appreciated. - thank you

(could not figure out how to attach xlsm file - but added it to the Hightail link below - thanks )

https://www.yousendit.com/download/bXBZeFlhZy80b0JvZE1UQw
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Use this code to fill column B the way you did in your example.

Code:
Sub FillNumbers()


Dim loopCounter As Integer
Dim lastRow As Long
    lastRow = Range("A" & Rows.Count).End(xlUp).Offset(1).Row - 1
    
For loopCounter = 2 To lastRow Step 1


    If Cells(loopCounter, 1) = 1 Then
        Cells(loopCounter, 2).Value = 1
    Else
        Cells(loopCounter, 2).Value = Cells(loopCounter, 2).Offset(-1) + 1
    End If


Next




End Sub
 
Upvote 0
Hi Svendiamond , Months later... but I'm revisiting this one..

Now I'm trying to do this same thing , but not all values begin with "1"... Do you know how this might be possible if the beginning numerical values are varying ? (i.e. - not always strting with "1". So, find current value, and then count upwards sequentially from there..)

much thanks , A
 
Upvote 0
Hmm, well your shared file is expired so I can't download it again. I don't remember what your sheet looks like. Best way to show me what your sheet looks like is to install the Mr Excel HTML Maker (it will also make future questions easier to solve) from this link: http://www.mrexcel.com/forum/about-board/508133-attachments.html#post2545970

But if you can't install the add-in, I guess just upload your file again. Or explain in more detail. I'm sure there is an easy solution for your problem.
 
Upvote 0

Forum statistics

Threads
1,214,878
Messages
6,122,062
Members
449,064
Latest member
scottdog129

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