Consulting

Results 1 to 3 of 3

Thread: trouble hiding columns

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Oct 2017
    Posts
    8
    Location

    Question trouble hiding columns

    Hi everyone,

    I am trying to hide a column using the below method:

    Range("D:MY1").EntireColumn.Hidden = True

    For which i receive the "Method Range of object global failed"

    When I change to this: Sheets("TEST").Range("D:MY1").EntireColumn.Hidden = True

    I get : Application defined or object defined error.

    However in a separate procedure I have used:

    Range("2:361").EntireRow.Hidden = True

    Which has worked completely fine, hence why I'm, confused this method has not worked for columns.

    I also much prefer referencing to columns in numbers, so if anyone could also let me know if that's possible here that would be great!

    Thanks in advance!!!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Range("D:MY1") doesn't return a valid range because you have it 'from all of Col D to the cell MY1'

    Try one of these

     Range("D1:MY1").EntireColumn.Hidden = True
    or

     Range("D:MY").Hidden = True
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Oct 2017
    Posts
    8
    Location
    Thanks so much, I didn't realise how stupid I was being, must have been staring at it too long!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •