+ Reply to Thread
Results 1 to 7 of 7

VBA To Run when changing worksheets

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    VBA To Run when changing worksheets

    Hi,

    I have set a Auto_Open VBA code to switch off Calculations when opening a large workbook which works fine.

    However i would now like to calculate each worksheet as i select that individual worksheet

    I know you can use the
    Please Login or Register  to view this content.
    code but this requires the amendment of a specified cell on that worksheet to activate the code, i want it to happen automatically when opening that worksheet without having to amend any cell.

    Can this be done?

    Thanks

    Simon

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA To Run when changing worksheets

    use the worksheet_activate event or probably easier to use the workbook_sheetactivate event in the thisworkbook module
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: VBA To Run when changing worksheets

    Great thanks that worked.

    Also i have this code to run calculations on teh activesheet when a change occurs on that sheet but also to then open another sheet to run calculations on, the first calculation works great but it is actually quicker for me to just go to the Store Balance Sheet tab and click Formulas/Calculate Sheet.

    Is it just my code thats making it slower?

    Please Login or Register  to view this content.
    Many Thanks

    Simon

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA To Run when changing worksheets

    if you have sheetactivate code in place then activating the sheet and then calculating it is a double calculation-use
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: VBA To Run when changing worksheets

    Thanks

    The trouble is that there are many sheets in the workbook which each need calculating but i only want to calculate the Private Sub Worksheet and the Store Balance Sheet worksheet hence the Activesheet statement i used. The code you gave above calculates the whole workbook....can u specify only Store Balance Sheet somehow?

    Thanks again

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA To Run when changing worksheets

    the code above specifies the two sheets to calculate

  7. #7
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: VBA To Run when changing worksheets

    Ah ok i thought it was doing the lot but its because the calculations on the store balance sheet are so plentyful it takes a little while

    Thanks for you help

+ 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