none
vba code to clear cells in 2 columns if it meets criteria RRS feed

  • Question

  • Dear Developers!

    I am in need of recommendations in my code below. Basically, what it does is to clear cell contents of Col C

    and D if col A says "XXX".I am having an error on this piece of code

    Cells(jrow, "C").Clear.contents


    'If A is XXX blank out cells in Col C and D Dim Nrow As Long, jrow As Long Nrow = Cells(Rows.Count, "A").End(xlUp).row For jrow = Nrow To 1 Step -1 If Cells(jrow, "A") = "XXX" And Cells(jrow, "C") = "ABC" And Cells(jrow, "D") = "DEF" Then Cells(jrow, "C").Clear.contents End If Next jrow


    Wednesday, April 18, 2018 5:40 PM

Answers

  • Change

                Cells(jrow, "C").Clear.contents

    to

                Cells(jrow, "C").ClearContents


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by IamJackie Wednesday, April 18, 2018 6:03 PM
    Wednesday, April 18, 2018 5:50 PM

All replies

  • Change

                Cells(jrow, "C").Clear.contents

    to

                Cells(jrow, "C").ClearContents


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by IamJackie Wednesday, April 18, 2018 6:03 PM
    Wednesday, April 18, 2018 5:50 PM
  • It worked! Thank you! 
    Wednesday, April 18, 2018 6:03 PM