Consulting

Results 1 to 3 of 3

Thread: trouble hiding columns

  1. #1

    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
    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 
    
    
    Formatting tags added by mark007
    or

    Range("D:MY").Hidden = True 
    
    
    Formatting tags added by mark007
    Paul

    ------------------------------------------------------------------------------------------------------------------------
    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)
    (multiple files can be selected while holding Ctrl key) / 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
    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
  •