+ Reply to Thread
Results 1 to 6 of 6

Insert/hide rows and colums on one sheet

  1. #1
    Registered User
    Join Date
    05-04-2015
    Location
    South Africa
    MS-Off Ver
    office for Mac
    Posts
    97

    Question Insert/hide rows and colums on one sheet

    Hi all,

    I am very new to this site, so I do hope you can assist me. I am very new to VBA.

    I am developing a calculator tool, and need to hide rows and columns, based on the choices of two dropdown boxes. I have attached the spreadsheet for your perusal.

    I have the following VBA for hiding and showing the rows, but cannot get the one for the columns to integrate with this.

    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$8" Then
    If Range("C8").Value = "Senior Management" Then
    Rows("10:50").EntireRow.Hidden = False
    Rows("51:128").EntireRow.Hidden = True
    ElseIf Range("C8").Value = "Middle Management" Then
    Rows("10:50").EntireRow.Hidden = True
    Rows("92:133").EntireRow.Hidden = True
    Rows("51:92").EntireRow.Hidden = False
    ElseIf Range("C8").Value = "Junior Management" Then
    Rows("10:50").EntireRow.Hidden = True
    Rows("92:133").EntireRow.Hidden = False
    Rows("51:92").EntireRow.Hidden = True
    End If
    End If
    End Sub

    But I would like to hide columns ("G"J"), if cell C4 is "Interpretation 1", then hide column F and column("I:J") when cell C4 is Interpretation2" etc etc. I have attached the sheet for your attention. Please can you help?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Insert/hide rows and colums on one sheet

    Please Login or Register  to view this content.

    Or

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 05-04-2015 at 08:03 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    05-04-2015
    Location
    South Africa
    MS-Off Ver
    office for Mac
    Posts
    97

    Re: Insert/hide rows and colums on one sheet

    Dear mehmetcik,

    Thank you very much for your reply. I do appreciate this.

    Can you please assist me in integrating this code into the existing code which I have posted in my previous post. I cannot seem to figure it out. I would really appreciate it.

    Regards

  4. #4
    Registered User
    Join Date
    05-04-2015
    Location
    South Africa
    MS-Off Ver
    office for Mac
    Posts
    97

    Question Re: Insert/hide rows and colums on one sheet

    Dear mehmetcik,

    Thank you very much for your reply. I do appreciate this.

    Can you please assist me in integrating this code into the existing code which I have posted in my previous post. I cannot seem to figure it out. I would really appreciate it.

    Regards

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Insert/hide rows and colums on one sheet

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-04-2015
    Location
    South Africa
    MS-Off Ver
    office for Mac
    Posts
    97

    Re: Insert/hide rows and colums on one sheet

    Thank you SOOOO much. I do appreciate this so much! I would like to add another few options, but it does not want to accept my code. Do you mind having a look where I am going wrong. I will appreciate this very much. Please help. here is the code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$8" Then
    If Range("C8").Value = "Senior Management" Then
    Rows("10:50").EntireRow.Hidden = False
    Rows("51:128").EntireRow.Hidden = True
    ElseIf Range("C8").Value = "Middle Management" Then
    Rows("10:50").EntireRow.Hidden = True
    Rows("92:133").EntireRow.Hidden = True
    Rows("51:92").EntireRow.Hidden = False
    ElseIf Range("C8").Value = "Junior Management" Then
    Rows("10:50").EntireRow.Hidden = True
    Rows("92:133").EntireRow.Hidden = False
    Rows("51:92").EntireRow.Hidden = True
    End If
    End If
    If Range("C4").Value = "Interpretation 1" Then
    Range("G:J").EntireColumn.Hidden = True
    ElseIf Range("C4").Value = "Interpretation 2" Then
    Range("F:F,I:J").EntireColumn.Hidden = True
    ElseIf Range("C4").Value = "Interpretation 3" Then
    Range("F:G,J:J").EntireColumn.Hidden = True
    ElseIf Range("C4").Value = "Interpretation 4" Then
    Range("F:I").EntireColumn.Hidden = True
    ElseIf Range("C4").Value = "ALL" Then
    Range("F:J").EntireColumn.Hidden = False
    End Sub

+ 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. VBA to hide rows/colums when the value is from another sheet
    By varmoh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2015, 09:12 AM
  2. Hide colums & rows with VBA & vlookup (if neccessary)
    By Crispy85 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2013, 06:52 AM
  3. Replies: 1
    Last Post: 12-02-2011, 09:03 AM
  4. Chart disappears if you hide rows/colums with data.
    By Philip Gump in forum Excel General
    Replies: 1
    Last Post: 04-02-2006, 11:40 PM
  5. What is the quickest way to hide a lot of rows and colums ?
    By Stephen Tyrrell in forum Excel General
    Replies: 2
    Last Post: 08-19-2005, 04:05 AM

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