+ Reply to Thread
Results 1 to 7 of 7

Hide different columns on different worksheets

  1. #1
    Forum Contributor
    Join Date
    09-25-2013
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2013
    Posts
    115

    Hide different columns on different worksheets

    Hi Everyone

    This is the code (2 macro's combined) that I run. I want to hide columns C & G after the first macro and columns B & H
    after the second macro.
    Any assistance to accomplish this will be much appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Hide different columns on different worksheets

    Hi, Tyso,

    what about recording a macro and looking at the code?

    Please Login or Register  to view this content.
    I wonder why not use the Advanced Filter to get a list unique values or use a Collection which could do both getting uniques and sort in one take.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    09-25-2013
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2013
    Posts
    115

    Re: Hide different columns on different worksheets

    Hi HaHoBe

    Thank you for your reply - much appreciated. I attached my file with the combined code mentioned in my post.
    You will notice that the first macro creates worksheets from Sheet 1 for items in Column A (VCol=1) and the second macro
    creates sheets for items in Column B.(VCol=2) from sheet 1. The sheets created by first macro, their columns C & G must be hidden
    The sheets created by second macro, their columns B & H must be hidden.
    I don't know where to insert your code.
    Attached Files Attached Files

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Hide different columns on different worksheets

    Hi, Tyso,

    any reason for using code like
    Please Login or Register  to view this content.
    And I would strongly recommend to get rid ot the extra spaces (both in the values as well as behind the sheetnames).

    Please Login or Register  to view this content.
    You should turn Application.ScreenUpdating back on after the macro is run - not off.

    A word on interrupting the code with MsgBoxes: I prefer to write the data into the Immediate Window or a textfile to keep it as the MsgBox will break the execution of code until itīs taken away.

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    09-25-2013
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2013
    Posts
    115

    Re: Hide different columns on different worksheets

    Hi HaHoBe

    I have inserted your code but it still doesn't hide the columns - see attached file.
    Don't know what I am doing wrong!
    Attached Files Attached Files

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Hide different columns on different worksheets

    Hi, Tyso,

    Don't know what I am doing wrong!
    Code doesnīt belong into ThisWorkbook (it canīt be triggered by any event but just be called from there) but in a standard module. I started to check with the first autofilter item and the columns where hidden on that sheet.

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Any update on my other questions?

    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    09-25-2013
    Location
    Cape Town South Africa
    MS-Off Ver
    Excel 2013
    Posts
    115

    Re: Hide different columns on different worksheets

    Hi HaHoBe

    Thank you so much - it works! You are absolutely fantastic!
    Also thank you for your advice and recommendations - I sincerely appreciate it very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Hide columns in multiple worksheets - each sheet has its own name
    By Tyso in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-29-2013, 01:53 PM
  2. [SOLVED] Hide columns in multiple worksheets
    By Tyso in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2013, 10:47 AM
  3. [SOLVED] Hide empty columns that appear the same from multiple worksheets
    By tinhtu in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-22-2012, 01:16 PM
  4. Hide empty columns from multiple worksheets
    By tinhtu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2012, 02:19 PM
  5. Checkbox to hide columns across multiple worksheets
    By BrakeJake in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2012, 09:49 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1