Problem with code for Clearing Content in Column Using User Input

  • Hi,


    Problem: The code runs, but does not clear the value entered in the inputbox, not sure what's wrong


    This works if I take out the DelValue in this line and insert the value such as


    [TABLE="width: 70"]

    [tr]


    [TD="width: 70, align: right"]200007649[/TD]

    [/tr]


    [/TABLE]


    If Cells(i, 2).Value = DelValue Then Cells(i, 2).ClearContents


    The code runs without errors, but does not clear the contents



    Sample Data for col 2


    [TABLE="width: 70"]

    [tr]


    [td]

    order_nr

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]200007649[/TD]

    [/tr]


    [tr]


    [TD="align: right"]200008649[/TD]

    [/tr]


    [tr]


    [TD="align: right"]200009649[/TD]

    [/tr]


    [tr]


    [TD="align: right"]200006649[/TD]

    [/tr]


    [tr]


    [TD="align: right"]200006649[/TD]

    [/tr]


    [tr]


    [TD="align: right"]200004649[/TD]

    [/tr]


    [/TABLE]



    Thank You in Advance
    James


  • Re: Problem with code for Clearing Content in Column Using User Input


    CountA only counts non-blank cells, so if there are blanks in that column the loop won't go all the way to the bottom. That may not be an issue in this case, but try this and see:



    If that don't work, post your workbook and someone might see something else causing your troubles.

  • Re: Problem with code for Clearing Content in Column Using User Input


    Hi jproffer.



    Thanks for the reply. That didn't work.. It's quite baffling why the code works if I explicitly put in the value, yet the Variable doesn't work.
    Other suggestions would appreciate it.
    James.


    Quote from jproffer;603958

    CountA only counts non-blank cells, so if there are blanks in that column the loop won't go all the way to the bottom. That may not be an issue in this case, but try this and see:



    If that don't work, post your workbook and someone might see something else causing your troubles.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!