Apply Script to More than One Column

  • This is my first post to the forum, but I have been an observer for quite a while. I am fairly new to VBA in excel and have run into a problem I am not sure how to resolve.

    I would like this to apply to columns D, E, F, and G (Meaning if Cell D10 = Coverage, cells D19:D23 are cleared and colored, etc). I know I could just repeat the code above, substituting Column D for Column C, but I’m sure there has to be a more efficient way. Any help would be greatly appreciated.

  • You can try this, it's untested as I don't have a sheet to test it with and I'm too lazy to create one. :cheers:

  • Thanks for the reply Bruce. The code works great.

    One additional question: As written, the Target Address is fixed in cell C10. Is it possible for a change in cell C10 to clear/highlight only the cells relevant cells in Column C, a change in D10 to clear/highlight only the relevant cells in Column D, etc...?

    If that isn't easy to accomplish, a change in either C10, D10, E10 etc to triggering the macro would also work.

    Thanks again!!

  • I think this is what you are asking for. :cheers:

  • My pleasure, thanks for the feedback. :cheers:

    I just noticed there's an error in the ElseIf line, if you read this just change it to look like the other line.
    In other words change the C10 part to match the other line that looks at what is in C10, D10 etc.

    Cells(10, c).Value

Participate now!

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