Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populate a range of cells from a function

I'm trying to write a function that will populate the cell that called
the function and x number of cells below it. For example

in cell A1, i make a call to my function "=GetList()"

GetList should put the numbers 1 - 10 in cells a1 - a10

its driving me crazy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Populate a range of cells from a function

Sorry to let you know that you can not use function to change cells'
contents. You need a sub rather than function.

Here is an indirect way without coding:

Assume you will put a number in A1 and the max X you willn enter is 20
in A2 type formula
=IF(ISNUMBER(A1), IF(A1-10,A1-1,""),"")
copy and paste formula to A3:A20
So when you type 10 in A1, A1 to A10 will be filled with 10 to 1 (in reverse
order) and A11 to A20 will be blank.

Hope this helps.


"4eyed" wrote in message
ups.com...
I'm trying to write a function that will populate the cell that called
the function and x number of cells below it. For example

in cell A1, i make a call to my function "=GetList()"

GetList should put the numbers 1 - 10 in cells a1 - a10

its driving me crazy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Populate a range of cells from a function

4eyed wrote:
I'm trying to write a function that will populate the cell that called
the function and x number of cells below it. For example

in cell A1, i make a call to my function "=GetList()"

GetList should put the numbers 1 - 10 in cells a1 - a10

its driving me crazy


David Chen's response should have been that with a function called from
a worksheet you cannot change the contents of cells *other than those
into which the function is entered*.

Array enter into A1:A10 =GetList()

Function GetList()
Dim arr
N = 10
ReDim arr(1 To N, 1 To 1)
For i = 1 To N
arr(i, 1) = i
Next
GetList = arr
End Function

Alan Beban

Reply
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
How to Delete blanks between a range and populate only the names inthe given range Yuvraj Excel Discussion (Misc queries) 2 November 4th 09 08:32 PM
Populate growing range of cells from Sheet1 to Sheet2 Brad New Users to Excel 10 July 23rd 09 08:32 AM
Function to populate cells?? BAS Excel Worksheet Functions 3 January 30th 08 06:56 PM
How to populate formula in range of vertical cells to next colum Robert Excel Worksheet Functions 0 November 17th 04 05:09 AM
Range of Cells to populate in a text box on a userform BenjiHarshbarge Excel Programming 1 November 4th 03 10:09 PM


All times are GMT +1. The time now is 04:59 PM.

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"