+ Reply to Thread
Results 1 to 20 of 20

VBA Code - If cell value = "xxx" then cell value = "yyy"

  1. #1
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    VBA Code - If cell value = "xxx" then cell value = "yyy"

    I currently have this formula for each cell in a column J

    =IF(F3="Content Final","Ready for Processing","") and so on

    But i would like this to be run off of VBA code since i do not want users to delete the formula in each cell. Anybody can help me with a code?

    this is the current code i am trying out to no avail.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Hi,

    Try using the Worksheet_Change event instead of the Worksheet_Calculate event:
    Please Login or Register  to view this content.
    Hope this helps

  3. #3
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    thank you very much for you help, but i am getting this message?

    2-21-2014 12-43-31 AM.png

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Could you please attach your workbook...?

  5. #5
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Quote Originally Posted by ajryan88 View Post
    Could you please attach your workbook...?
    Draft-TOC-(Product)-(Applicatiion_Number)-(SCN).xlsm

    here is the attached file

  6. #6
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    so basical;ly if i choose values in column F to content final, then column J should be Ready for processing.....

    thanks

  7. #7
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    oh and password would be 'sub2011' if you need to access them

  8. #8
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    First of all, I figured you wanted it to be a comment, so in the code that I gave you, change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Secondly, try unprotecting the VBA and run the macro again, and tell me if you get the same error message.

  9. #9
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Delete your Worksheet_Change subroutine and replace it with mine. I believe the error is occurring because you have multiple Worksheet_Change subroutines declared. Also, make the change that I mentioned in my previous post to have the cell value change rather than the cell comment.

    Let me know

  10. #10
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    thank you very much for all your hep. but i am getting this message now? and its freezingout-of-stack.png but the value did change to "ready for processing" its just that it keeps freezing.

    i really appreciate all your help, it is 1 am my time and i am hitting the bed. Hope to see your answer tomorrow morining once i awake.

  11. #11
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    All fixed.

    This error was occurring because the procedure was being called again once we changed the value in column J, and Excel doesn't like it when a procedure calls itself.

    The solution was to disable events while the value in column J was changed.

    Hope this helps

  12. #12
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    All fixed.

    This error was occurring because the procedure was being called again once we changed the value in column J, and Excel doesn't like it when a procedure calls itself.

    The solution was to disable events while the value in column J was changed.

    Hope this helps

  13. #13
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Sorry about the duplicate post, had a problem with the site and it uploaded twice

  14. #14
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    thank yuo very much! this forum rocks

  15. #15
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Ajryan, sorry to bother you again, but i am now trying to offset the column to the left. So basically if values of cells in column J is "Reset to Draft" then cells in column F will equal "Draft"

    This is the current code i have but nothing is happening?

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    i figured it out.

    Thanks again AJ

  17. #17
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    You're welcome.

    It isn't working because there can only be one Worksheet_Change event, so you need to combine your code into the existing subroutine rather than creating a new one:
    Please Login or Register  to view this content.
    Give me 5 minutes and I'll rewrite your code so that it is cleaner and easier to read, and I'll post the changed code back here

  18. #18
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Here you go, use this subroutine instead of the last one that I posted. Hope this helps
    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    No problems, please don't forget to mark this thread as solved

  20. #20
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code - If cell value = "xxx" then cell value = "yyy"

    Thank u!!!

+ 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] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  2. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 PM
  3. [SOLVED] Data validation: allow entry into a cell if other three cells have "X", "Y" and "Z"?
    By RogerRangeRover in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2013, 04:49 AM
  4. Replies: 0
    Last Post: 11-20-2012, 10:22 AM
  5. Replies: 1
    Last Post: 01-30-2006, 06:10 PM

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