+ Reply to Thread
Results 1 to 4 of 4

Code working on one sheet but not on another

  1. #1
    Registered User
    Join Date
    05-28-2019
    Location
    Edinburgh
    MS-Off Ver
    2013
    Posts
    92

    Code working on one sheet but not on another

    Hi guys, ive written a code, it works perfectly on the enthalpy balance sheet, the code for this can be found in the Coefficients_Q module. I have made a new sheet Enthalpy and copied the code and changed the cells appropriately into module 1 but it no longer seems to work. Can someone please tell me why?
    Attached Files Attached Files

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Code working on one sheet but not on another

    What does not work mean?

    It has a Stop which is not a command word. If one wants to exit a sub use Exit Sub.

    I would use a Select Case rather than multiple IFs. A lookup table would be a better route. Select, Selection, Activate, and such are seldom needed. When repeating code, if a pattern exists, it is easier to maintain one Sub and pass the changing parameters.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Code working on one sheet but not on another

    Hello jpe1,

    Your Code for the enthalpy balance sheet refers to Range A8 followed with an Offset of -5, while your Code for the enthalpy sheet refers to Range A6 followed with an Offset of -5. Since the Start Cells are not the same, you should also change the Offsets accordingly. So the Code for the enthalpy sheet should look something like below, etc.

    Please Login or Register  to view this content.
    And so on.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Registered User
    Join Date
    05-28-2019
    Location
    Edinburgh
    MS-Off Ver
    2013
    Posts
    92

    Re: Code working on one sheet but not on another

    Thank you, ive changed it, ive tried running the code but it keeps saying cant loop without a do, there is a do statement at the beginning but the code dosent seem to use it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] This code not working in a Protected Sheet, can any one pls edit this code
    By rajeshn_in in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2016, 01:08 AM
  2. Unprotect sheet code not working
    By Damian37 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2014, 12:51 PM
  3. Code working in one sheet but not the other?
    By freddieperez in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-13-2013, 12:52 PM
  4. VBA Sheet array code not working with drop down lists in master sheet
    By chiplaidlaw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2012, 11:01 AM
  5. Code working but on wrong sheet
    By pauldaddyadams in forum Excel General
    Replies: 6
    Last Post: 11-11-2011, 07:29 AM
  6. Code not working unless sheet is active
    By WAW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2010, 12:18 PM
  7. Code not working on new sheet copied from a sheet that works
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 10-20-2010, 08:54 AM

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