locked
VBA: Select Column that has a merged cell in it somewhere RRS feed

  • Question

  • Thanks for taking the time to read my question.

    I recorded this macro:

        Columns("I:I").Select
        Range("I2").Activate
        Selection.EntireColumn.Hidden = True

    When I click on Column "I" it only selects column I regardless of the merged cells that spans from A1 to L1.

    When I run the code, it selects all columns from A to L.

    How do I stop this from happening?

    Thanks,
    Brad

    Wednesday, April 25, 2018 11:33 PM

Answers

  • This is how:

    x = 2

    Range(Columns(x),Columns(x)).EntireColumn.Hidden = True

    Thanks,
    Brad

    • Marked as answer by mbrad Thursday, April 26, 2018 1:59 AM
    Thursday, April 26, 2018 1:59 AM

All replies

  • This is how:

    x = 2

    Range(Columns(x),Columns(x)).EntireColumn.Hidden = True

    Thanks,
    Brad

    • Marked as answer by mbrad Thursday, April 26, 2018 1:59 AM
    Thursday, April 26, 2018 1:59 AM
  • Hi,

    How would keep that column selected without the merged cells?

    It selects all columns from A to L in VBA instead of just column I.

        Columns("I:I").Select
    

    Tuesday, October 27, 2020 4:29 PM