+ Reply to Thread
Results 1 to 8 of 8

How to avoid repeat code

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    KETTERING ENGLAND
    MS-Off Ver
    Excel 2016
    Posts
    31

    How to avoid repeat code

    Hello everybody
    I am newbie at vba
    Can someone help me please?
    I,ve got the bellow code and working indepedent at each row 4,5 with target column B
    What i want is to make it work until row 50,without to repeat the code 50 times
    Note i want to work the rows indepedent and NOT let say if clear contents C4:G4 to clear
    as well C5:G5 etc

    If Not Intersect(Target, Range("B4")) Is Nothing Then
    If UCase(Range("B4")) = "" Then
    Application.EnableEvents = False
    Range("C4:G4").ClearContents
    Application.EnableEvents = True
    End If
    End If
    If Not Intersect(Target, Range("B5")) Is Nothing Then
    If UCase(Range("B5")) = "" Then
    Application.EnableEvents = False
    Range("C5:G5").ClearContents
    Application.EnableEvents = True
    End If
    End If


    Thanks

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,828

    Re: How to avoid repeat code

    Try:
    Please Login or Register  to view this content.
    Also, when posting code, please use code tags. To do that, highlight (select) your code and click the # icon in the menu.
    Last edited by Mumps1; 09-30-2018 at 10:23 AM.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    08-31-2012
    Location
    KETTERING ENGLAND
    MS-Off Ver
    Excel 2016
    Posts
    31

    Re: How to avoid repeat code

    Thank you so much

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,828

    Re: How to avoid repeat code

    You are very welcome.

  5. #5
    Registered User
    Join Date
    08-31-2012
    Location
    KETTERING ENGLAND
    MS-Off Ver
    Excel 2016
    Posts
    31

    Re: How to avoid repeat code

    One more thing for me it is very complicate for you maybe easy
    At following code I've got if Target Value = "DOR" Then transfer the values from Target Rows 7,19,16 to another sheet called BAYS at rows 9,7,8.
    This code work perfect. What I want is if change Target Value = " " then clear contents at sheet BAYS in rows 9,7,8

    Please Login or Register  to view this content.
    Thanks

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,828

    Re: How to avoid repeat code

    Maybe:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-31-2012
    Location
    KETTERING ENGLAND
    MS-Off Ver
    Excel 2016
    Posts
    31

    Re: How to avoid repeat code

    Thanks for try
    unfortunately not working

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,828

    Re: How to avoid repeat code

    Without seeing your actual file, it is difficult to suggest a solution. Please attach a copy of your file. De-sensitize it if necessary. Explain in detail what you want to do referring to specific cells, rows, columns and sheets.

+ 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] Avoid not responsive part of VBA code
    By Excelko in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2017, 04:16 PM
  2. VB Code to password protect VB Module to avoid other seeing the code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2015, 11:33 AM
  3. Can i avoid Locked Cells Using this Code getting Updated How can i edit this code
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-01-2014, 03:27 AM
  4. [SOLVED] help on vba code to avoid pop-up stage in middle of code....
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2013, 09:51 PM
  5. Code to avoid duplicate userforms
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2009, 08:30 AM
  6. Cleaning up code/avoid selecting
    By sportsranker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2008, 01:42 PM
  7. [SOLVED] How to protect a code with password to avoid mishandling
    By bobby in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-10-2005, 10:20 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