+ Reply to Thread
Results 1 to 4 of 4

Need help writing macro to replace one cell based on contents of adjacent cell

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Need help writing macro to replace one cell based on contents of adjacent cell

    I am trying to write a macro that performs the following:

    For each cell in Column A that contains "X"
    If the adjacent cell in Column B contains "Y"
    Delete contents of cell from Col A (or replace with blank)

    How would I do this?

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Need help writing macro to replace one cell based on contents of adjacent cell

    Hello there,


    To begin press Alt+F8 on your keyboard to bring up the macro window. Clear the contents in the macro name and then type ClearX. Select the Create option.

    In between the Sub ClearX() and End Sub copy and paste the below code

    Please Login or Register  to view this content.
    Close out of the visual basic window. Then press Alt+F8 again this time select the ClearX macro and select run.

    Let me know if this works for you!

    Thanks!

  3. #3
    Registered User
    Join Date
    07-24-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Need help writing macro to replace one cell based on contents of adjacent cell

    Works perfectly, thank you so much!

  4. #4
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Need help writing macro to replace one cell based on contents of adjacent cell

    Glad to help! Don't forget to mark this thread solved and maybe give a little star tap if I helped!

    Thanks!

+ 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