+ Reply to Thread
Results 1 to 2 of 2

Problem understanding how functions (Getbigger,rowsum,rowmax) works in visual macro

Hybrid View

imperial_saber Problem understanding how... 06-02-2009, 03:08 PM
Leith Ross Re: Help of Visual Macro... 06-02-2009, 03:29 PM
  1. #1
    Registered User
    Join Date
    06-02-2009
    Location
    California, United States
    MS-Off Ver
    Excel 2007
    Posts
    1

    Problem understanding how functions (Getbigger,rowsum,rowmax) works in visual macro

    Hello I am relatively new to this forum.
    I am currently stuck at these three problems and it would be very helpful if someone can help me on them.
    1.Write a Function named GetsBigger that has a parameter n. This function uses a For loop to generate n random numbers, (e.g., x = Rnd) and calculates and returns how many times the new random number is bigger than the biggest random number generated so far. Hint: Inside the function, have variables for (a) the current random number, (b) the biggest random number seen so far, and (c) a count of how many times the current random number is bigger than the biggest so far. Each iteration of the loop updates these variables as necessary. Hint: Use an appropriate If statement (I used the form with no Else; also, see the subroutines and function in the workbook Lecture 26 for "Calculating Pi", which has all the VB elements needed for this function. Note that GetsBigger(1) should return 1 I have called that function in column A of the GetsBigger worksheet. The result shows as #NAME? until you define the function. For 100,000 numbers, the average (calculate by cell A12) should be about 13.

    2.Write a Function named RowSum that has three parameter row, startC, and stopC. This function uses a For loop to generate values from all the column cells in the specfied row (between startC and stopC) and calculates and returns the sum of these values. Hint: Set a result variable equal to 0 and then increment it inside the loop, adding the value in each cell visited. I have called that function in column A of the Stats worksheet, for all columns in rows 1 and 2 (in cells A5 and A6) and for columns 3 through 6 in rows 1 and 2 (in cells A8 and A9). The result shows as #NAME? until you define the function.

    3.Write a Function named RowMax that has three parameter row, startC, and stopC. This function uses a For loop to generate values from all the column cells in the specfied row (between startC and stopC) and calculates and returns the maximum(biggest) of these values. Hint: Set a result variable equal to the value in cell specified by row and startC and look at every other cell value in that row, updating the result to that value if it is bigger. I have called that function in column B of the Stats worksheet, for all columns in rows 1 and 2 (in cells B5 and B6) and for columns 3 through 6 in rows 1 and 2 (in cells B8 and B9). The result shows as #NAME? until you define the function.
    Last edited by imperial_saber; 06-02-2009 at 04:21 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help of Visual Macro problems

    Hello imperial_saber,

    Welcome to the Forum!

    This looks like a homework assignment. Your post title should convey a brief description of what you need help with. Please do not use general words and phrases like "Help!", "need advice", "doesn't work", etc. Your present title doesn't tell anyone what your question is or what type of problems you are experiencing.

    As a new member of the forum, please take a few minutes and read the forum rules for posting and general etiquette. To see them, click on the link below...

    Forum Rules
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1