View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
galimi[_2_] galimi[_2_] is offline
external usenet poster
 
Posts: 65
Default Function to automatically fill in an array of cells

Following is some code which I hope will put you on the right path

Public Function fill(initial_value, end_value, step_increment)

MaxVal = (end_value - initial_value) / step_increment + 1
Dim vl()
ReDim vl(MaxVal)

For z = initial_value To end_value Step step_increment


vl(cntr) = z
cntr = cntr + 1

Next

vl(cntr) = end_value
fill = vl

End Function

This function of course has to be entered as an array on a row, spanning the
number of columns for the total number of increments in your step that must
be taken. The application.thiscell method is extremely useful, but, not for
a function.
--
http://HelpExcel.com
1-888-INGENIO
1-888-464-3646
x0197758


"Maarten" wrote:

Hello,

Is it possible to construct a function for the following problem:
Im looking for a method in Excel to automatically fill in a range of cells
(column A), given a value for the step and an end value.
Example: If
InitialValue (A1) = 0.5
Step = 0.1
EndValue = 1
Then column A should go from 0.5 (in cell A1) to 1 (in cell A6) in steps of
0.1. If I adjust the step to 0.05, column A should automatically become 2
times longer.
Can somebody help me with this?
Thanks,
Maarten