|
#1
|
||||
|
||||
I'm assuming you have some other code that loops through the rows and all you're after is the basic logic for working out the #s to populate the 'spread' range. The following code shows how to do that, taking a value entered in an InputBox as the # to spread and the selected range as the cells over which the spreading is to be done: Code:
Sub Demo() Dim i As Long, j As Long, k As Long, l As Long, x As Long i = CLng(InputBox("Number to spread?", , 0)) j = Selection.Cells.Count k = -Int(-i / j) l = k * j - i For x = 1 To l Selection.Cells(x).Value = k - 1 Next For x = l + 1 To j Selection.Cells(x).Value = k Next End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Counting Number of Months from a static date | bremen22 | Excel | 4 | 11-25-2013 11:57 AM |
Converting serial number to years, months and days | hannu | Excel | 6 | 02-14-2013 09:21 PM |
How to count year lapse (rounded off) based on specific date | KIM SOLIS | Excel | 1 | 11-01-2011 10:50 AM |
Creative Ways for a year-to-year comparison??? | ridonkulous5 | Excel | 1 | 03-23-2011 04:49 PM |
Setting up recurring months to skip some months etc. | dwelch@ykfireprevention.c | Outlook | 0 | 11-30-2010 10:15 AM |