Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 37

Thread: macro in excel

  1. #1
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location

    macro in excel

    can someone plz help me out to write a macro for the format below:
    = 43.29+67.86
    = 111.15+67.86
    = 179.01+67.86.... same operation to be done in the other columns with different values. it would be a grt help!!!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What exactly is the macro supposed to look at and what is it supposed to do?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location
    Quote Originally Posted by xld View Post
    What exactly is the macro supposed to look at and what is it supposed to do?
    step 1: it should add up 43.29+67.86. which is = 111.15.
    step 2: with 111.15 it should add 67.86. so, 111.15+67.86=179.01
    step 3 again with 179.01, 67.86 is to be added. so, 179.01+67.86=246.87......

    for next column 53.61+46.24=99.85
    =146.09+46.24
    =192.33+46.24.... for other columns different values are there.

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    My dearest writwika,

    We cannot look over your shoulder and see the workbook you have in front of you.

    "step 1: it should add up 43.29+67.86. which is = 111.15."

    Okay, but pray tell, where are we to find these numbers to add? We cannot be a great help if you do not express from wherein the values are to be found...

    I see that it is your first thread. Welcome to the forum, vbax is great! We just need you to 'draw' a clearer 'picture' of what you are wanting to do. For instance, "I want to add all numerical values in column A, and plunk the return in cell n. Then the same thing for columns B through n.", would give us a clue as to the goal...

    Mark

  5. #5
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location
    a random variable is taken. to this we add 11.47. again, we add 11.47 to the result. this process goes on 5500 times. 11.47 is fixed. please help me out. please do say if u have a doubt still.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No wonder we didn't understand. 11.47 was pretending to be 67.86. Can't say it is fully explained yet, but here is one attempt

    =A1*11.47*5500
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location
    67.86 is to be added to a random variable in the 1st cell. now from the next row i want to keep on adding 67.86 to the previous result. this goes on 5500 times. it will look like:
    let us take the random variable as 11.47.
    = 11.47+67.86
    = 79.33+67.86
    =147.19+67.86... now can u get a picture of it???

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    .. now can u get a picture of it???
    So can we assume that you mean that cell A1 + 67.86, and fill down for 5500 rows?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    To what purpose ??

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Quote Originally Posted by snb View Post
    To what purpose ??
    you out remember the bloke in Canada who shifted towns???
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    So, he's back ?

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Aussiebear View Post
    So can we assume that you mean that cell A1 + 67.86, and fill down for 5500 rows?
    Nah, he means that some random number in a cell gets multiplied by 67.86, then multiplied by 67.86, then gets ... 5500 times. But he doesn't say whether that random number is input by someone/something, whether he wants the code to generate it, what the bounds of that random number are, whether he wants that number multiplied by 67.86 5500 times whenever that random number appears, whether he wants a button for the user to press every time, or what. Despite asking for clarification the OP only seems to be able to regurgitate - sounds that this may be homework.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  13. #13
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location
    the random variable we select should be any number less than 100 and user does NOT input it. the cell no changes in every step. A1+67.86. then A2+67.86. A3+67.86....this goes on 5500 times automatically. so the execution should stop at A5500.

  14. #14
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    @ writwika, why didn't you say so initially as this would have cleared up the confusion surrounding this thread
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  15. #15
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location
    plz provide the macro for it. it is urgent.

  16. #16
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    If it's urgent hire a software specialist.

  17. #17
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Sub ken()  
      Range("A1").Value = Application.MRound(Rnd() * 99.99, 0.01)
      Range("A2:A5500").Formula = "=A1+67.86"
      Range("A2:A5500").NumberFormat = "0.00"
    End Sub

  18. #18
    VBAX Regular
    Joined
    Sep 2014
    Posts
    17
    Location
    thanks for the reply but the code is not working. showing runtimme error.

  19. #19
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by writwika View Post
    thanks for the reply but the code is not working. showing runtimme error.
    I copied Kenneth's suggestion verbatim, plunked it in a Standard Module, and it runs fine.

  20. #20
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Most likely you are running a version older than 2010. Replace the mround function with this one.
    Sub ken()    Range("A1").Value = Round(Rnd() * 99.99, 2)
        Range("A2:A5500").Formula = "=A1+67.86"
        Range("A2:A5500").NumberFormat = "0.00"
    End Sub
    When it errors, you can use Debug to see where it errored. You can also step through code by pressing F8 to debug line by line.

Posting Permissions

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