+ Reply to Thread
Results 1 to 13 of 13

Calculation VB Code Issue

  1. #1
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Calculation VB Code Issue

    Hi,

    i have the following code in my excel objects

    Please Login or Register  to view this content.
    It seems to be making the copy and paste features not work anymore.

    Do you see a work around for this?

    Thanks,

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Calculation VB Code Issue

    Good afternoon hedge
    Quote Originally Posted by hedge View Post
    i have the following code in my excel objects

    It seems to be making the copy and paste features not work anymore.

    Do you see a work around for this?
    This code is firing everytime a different cell is selected and in doing so it clears anything copied to the clipboard. Is it really necessary to use the Selection_Change event? You'd probably be better hanging it on the Worksheet_Change event instead, thus:
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    If I use that new code, when would a calculate be done?

  4. #4
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    My Main goal with the calculate code was that, I have function that I created in my VB code. When I change some of the values in the vb editor and then went back to my workbook, I didnt want to have to hit F9 to recalc.

    This was the only way I was able to get that done.

    Any ideas?

    Thanks

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Calculation VB Code Issue

    Hi hedge
    Quote Originally Posted by hedge View Post
    If I use that new code, when would a calculate be done?
    The recalc will be done every time you add something (anything) to the worksheet, as opposed to everytime you change the selected cell.

    It is unlikely that anything would change in your workbook without you doing something.

    Are you saying that you have a UDF in your workbook as well? If you would like to post the code it might be possible (depending on what it does) that someone may be able to suggest a way to make it fully volatile (update when a change occurs, and not need the code I suggested).

    HTH

    DominicB

  6. #6
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    Hi,

    Code is enclosed

    Please Login or Register  to view this content.
    The problem is when I change one of the tiers or steps and then close the vb editor the cell with the formula doesn't update until I hit F9.

    that is why I added this code

    Please Login or Register  to view this content.
    Then when I clicked back to the worksheet everything updated.

    Thanks,

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Calculation VB Code Issue

    I would not expect the sheet to auto re calculate when you change the underlying code for a function. You would have to manually recalc.

    Once the function is stable, in that you stop changing the code, then it should update when any of the cells it references change.

    Other wise you will need to use the Volatile statement in the function.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    thanks

    I guess there rely isn't a solution to my problem

    I will just have to disable to calculate code, and then hit f9 whenever I change the user defined function.

    Thanks

  9. #9
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    Hi,
    Do you think the -

    Please Login or Register  to view this content.
    could be used here?

    how does excel activate a window?

    Thanks,

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Calculation VB Code Issue

    You can acitvate a sheet by selecting it. If the sheet is already selected you will need to select another sheet first. But hey you already knew that as I answered your other post on exactly that topic.

    I think you need to stop and think about your function and why it is that you need to keep changing it. If there are variable elements to your function perhaps those to should be information you pass to the function.

  11. #11
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    Sorry about the double post.

    Yes, I guess I will have to change how the function is working.

    The only problem I had when I added this code

    Please Login or Register  to view this content.
    is that the copy and paste feature was now disabled.

    Is there anyway to manipulate the copy/paste feature or clipboard options with VB code?

    Thanks again.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Calculation VB Code Issue

    If you put the Tier and Step constants in the workbook and passed them to the function as Andy suggests, everything would recalculate automatically.

    You're digging yourself into a deeper and deeper hole.
    Entia non sunt multiplicanda sine necessitate

  13. #13
    Registered User
    Join Date
    11-19-2008
    Location
    new york
    Posts
    28

    Re: Calculation VB Code Issue

    ok thanks for your help on this topic.

    now the hard part - telling my Boss we need to revamp her workbook.

    Thanks again

+ 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