LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Autofill missing numbers

Hi Tim,

Quick & dirty:

Push ALT + F11, insert a macro module and paste this:

Option Explicit

Private Enum xlCI 'Excel Color Index
: xlCIBlack = 1: xlCIWhite: xlCIRed: xlCIBrightGreen: xlCIBlue '1 - 5
: xlCIYellow: xlCIPink: xlCITurquoise: xlCIDarkRed: xlCIGreen '6 - 10
: xlCIDarkBlue: xlCIDarkYellow: xlCIViolet: xlCITeal: xlCIGray25 '11 -
15
: xlCIGray50: xlCIPeriwinkle: xlCIPlum: xlCIIvory: xlCILightTurquoise
'16 - 20
: xlCIDarkPurple: xlCICoral: xlCIOceanBlue: xlCIIceBlue: xlCILightBrown
'21 - 25
: xlCIMagenta2: xlCIYellow2: xlCICyan2: xlCIDarkPink: xlCIDarkBrown '26
- 30
: xlCIDarkTurquoise: xlCISeaBlue: xlCISkyBlue: xlCILightTurquoise2:
xlCILightGreen '31 - 35
: xlCILightYellow: xlCIPaleBlue: xlCIRose: xlCILavender: xlCITan '36 -
40
: xlCILightBlue: xlCIAqua: xlCILime: xlCIGold: xlCILightOrange '41 - 45
: xlCIOrange: xlCIBlueGray: xlCIGray40: xlCIDarkTeal: xlCISeaGreen '46
- 50
: xlCIDarkGreen: xlCIGreenBrown: xlCIBrown: xlCIDarkPink2: xlCIIndigo
'51 - 55
: xlCIGray80 '56
End Enum


Sub linear_interpolation(Optional b_horizontal = False)
'Performs linear interpolation:
'In each row for empty cells between those with values
'Define area to be interpolated with name "interpolation_data"
'Example: <empty <empty 12 <empty <empty 21 <empty
'Will become: <empty <empty 12 15 18 21 <empty
'Original filled cells will be coloured and different colour
'will be applied for interpolated cell values to be able to
'rerun this program.

Dim i As Long, j As Long, k As Long
Dim CalcModus As Long
Dim UpdateModus As Long
Dim r As Range
Dim d1 As Double, dstep As Double
Dim lng_FI As Long, lng_SI As Long

CalcModus = Application.Calculation
Application.Calculation = xlCalculationManual
UpdateModus = Application.ScreenUpdating
Application.ScreenUpdating = False

Set r = Range("interpolation_data")
If b_horizontal Then
For i = 1 To r.Rows.Count
k = 0
Application.StatusBar = "Processing row " & i & " ..."
For j = 1 To r.Columns.Count
If r.Cells(i, j).Interior.ColorIndex < xlCIYellow _
And Not IsEmpty(r.Cells(i, j)) Then
If r.Cells(i, j) < "" Then
If k 0 Then
dstep = (r.Cells(i, j).Value - d1) / (j - k)
Do While k + 1 < j
r.Cells(i, k + 1).Formula = r.Cells(i, k) +
dstep
r.Cells(i, k + 1).Interior.ColorIndex =
xlCIYellow
k = k + 1
Loop
End If
k = j
r.Cells(i, j).Interior.ColorIndex = xlCILime
d1 = r.Cells(i, j).Value
End If
End If
Next j
Next i
Else
For i = 1 To r.Columns.Count
k = 0
Application.StatusBar = "Processing column " & i & " ..."
For j = 1 To r.Rows.Count
If r.Cells(j, i).Interior.ColorIndex < xlCIYellow _
And Not IsEmpty(r.Cells(j, i)) Then
If r.Cells(j, i) < "" Then
If k 0 Then
dstep = (r.Cells(j, i).Value - d1) / (j - k)
Do While k + 1 < j
r.Cells(k + 1, i).Formula = r.Cells(k, i) +
dstep
r.Cells(k + 1, i).Interior.ColorIndex =
xlCIYellow
k = k + 1
Loop
End If
k = j
r.Cells(j, i).Interior.ColorIndex = xlCILime
d1 = r.Cells(j, i).Value
End If
End If
Next j
Next i
End If

Application.StatusBar = False

Application.Calculation = CalcModus
Application.ScreenUpdating = UpdateModus

End Sub

Then select your data area (your cells from 100 to 79), then
Insert/Name/Define and name that range "interpolation_data".

Insert a macro button and link it to my program or start the program
manually. Should work - but only if you do not skip a day.

HTH,
Bernd



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoFill Numbers- shows up ### tearose Excel Worksheet Functions 2 November 1st 09 03:56 PM
AutoFill of Numbers ithinkican2 Excel Worksheet Functions 3 August 21st 08 12:57 AM
numbers won't autofill [email protected] Excel Discussion (Misc queries) 2 February 18th 08 12:44 AM
to find missing serial numbers in randomly generated numbers B.H. Hadi Excel Worksheet Functions 2 December 1st 05 10:56 PM
Q. Autofill question: Can I autofill alpha characters like I can numbers? George[_22_] Excel Programming 5 August 7th 04 10:33 AM


All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"