Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
AutoFill Numbers- shows up ### | Excel Worksheet Functions | |||
AutoFill of Numbers | Excel Worksheet Functions | |||
numbers won't autofill | Excel Discussion (Misc queries) | |||
to find missing serial numbers in randomly generated numbers | Excel Worksheet Functions | |||
Q. Autofill question: Can I autofill alpha characters like I can numbers? | Excel Programming |