+ Reply to Thread
Results 1 to 7 of 7

What is the VBA language to copy formula cell and apply formula to set of cells?

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    6

    What is the VBA language to copy formula cell and apply formula to set of cells?

    First, I just wanted to let you all know that I am a very very new at any type of programming. What I am attempting to do is write a program that will ask for user input to seven variables. After inputting the variables, I would like for them to display on a worksheet. I would then like for those values to be entered into an expression with the result being displayed as a table plus a plot.
    The following is the expression that will be used:

    P = R*T/(v-b) - a/v^2

    With the following variables being asked for user input:
    'a', 'b', 'R', 'v', Initial T, Final T, Temp stepsize ('a', 'b', 'R', 'v' are constants so it would be preferable if the user need not enter them)

    The table generated would be in the form: "Temp, Pressure" Having n=(Tf-Ti)/stepsize values listed
    The plot would have Temp on the abscissa and Pressure on the other axis

    I have tried the following two codes without luck:
    Ideally, The first one would give you the list of values by entering =pressure(Ti,Tf,Stepsize) into one of the cells. However, I only get one output. (Not sure how to display a result after each iteration in a loop.) The second one is my attempt to have the program do what I would normally do if I were to copy and paste a formula down a row of cells. Any help would be greatly appreciated! I've been trying to figure this out for about 12 hours now!

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 08-24-2012 at 10:30 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: What is the VBA language to copy formula cell and apply formula to set of cells?

    Where and how do you use the pressure function??
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    08-24-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: What is the VBA language to copy formula cell and apply formula to set of cells?

    For my first attempt at coding it is pTotal = R * T / (v - b) - a / v ^ 2 but the way I have it set-up I will only get the final value when i=10 instead of getting values for each i in i=1 to n. If I knew how to insert the correct language then I would be about halfway to getting what I would like to have as a result.

    For my second attempt, I didn't get to the point of inserting the pressure function. I was first trying to understand how to display T=0,25,50,.....500 in increments of 25 or, rather, in increments equal to stepsize which in my case will be 25.

    Basically the pressure function will be the expression for which the other variable values will be translated into some value for which I would like to plot that corresponds to the T value which produced it.

    I hope this helps. If not, then let me know and I will try to clarify what I mean. Thanks!

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: What is the VBA language to copy formula cell and apply formula to set of cells?

    This would not happen to be a homework assignment?
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  5. #5
    Registered User
    Join Date
    08-19-2012
    Location
    Cambodia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: What is the VBA language to copy formula cell and apply formula to set of cells?


  6. #6
    Registered User
    Join Date
    08-24-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: What is the VBA language to copy formula cell and apply formula to set of cells?

    @JapanDave Yes it is a homework assignment. I am not one to cheat in order to just get the answer without understanding but I understand your concern. The class I am taking is Numerical Methods for Engineers. Unfortunately, the class does not have programming as a prerequisite even though it is a requisite for completing the homework. I've read parts of the required textbook for examples etc and I've read the examples my professor posted for us to learn how to approach the problem. I've also have been reading a book entitled, "VBA for Excel Made Simple" by Keith Darlington but I've yet to come across the concepts that the problem appears to require. In truth, I don't want the specific answer to the problem but I think it would be beneficial if an example were offered which covered similar concepts. I really want to learn how to do this without a specific and direct answer because that would take away from the learning process. It's getting late here at the moment but I will take a look at what darayuk posted tomorrow morning and see if I can understand how to go about writing the proper code. (Thank You darayuk BTW). Any help in that manner will be appreciated. Thanks. :-)

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: What is the VBA language to copy formula cell and apply formula to set of cells?

    You don't want the loop within your function - you need to invoke the function - for each display!

    What is your display by the way? Have you written a complete routine? Whether correct or not, we could see your intention with a complete routine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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