+ Reply to Thread
Results 1 to 8 of 8

Unhide cells and columns in selected tabs

  1. #1
    Registered User
    Join Date
    08-02-2015
    Location
    Newcastle, England
    MS-Off Ver
    2010
    Posts
    37

    Unhide cells and columns in selected tabs

    Hi,

    I've created a UserForm populated with the names of all the worksheets within the workbook. I want to unhide all cells and columns in the worksheets selected by the user when the 'OK' button is pressed but not sure how to go about this?

    Thanks in advance

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Unhide cells and columns in selected tabs

    instead of hiding all columns and cells, just hide the worksheet.

    sheets("nameOfSheet").visible = false

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Unhide cells and columns in selected tabs

    If you want to unhide all columns and rows in all worksheets this is what you would do:

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Registered User
    Join Date
    08-02-2015
    Location
    Newcastle, England
    MS-Off Ver
    2010
    Posts
    37

    Re: Unhide cells and columns in selected tabs

    Thanks both, this was the first thing I tried (as I've used the code before and it works perfectly), but i get an error saying 'Unable to set hidden property of the range class'?

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Unhide cells and columns in selected tabs

    Try this code that will unhide all rows and columns for visible sheets only
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  6. #6
    Registered User
    Join Date
    08-02-2015
    Location
    Newcastle, England
    MS-Off Ver
    2010
    Posts
    37

    Re: Unhide cells and columns in selected tabs

    Perhaps if I post the code I've currently got within the userform, that will help (there currently isn't any code for the "OK" as that's what I'm trying to create at the moment)

    Option Explicit
    Dim ws As Worksheet
    Dim i As Integer
    Dim counter As Integer
    'Click Ok to unhide all cells & columns, then execute export of data into auto-loader worksheet
    Private Sub CommandButton1_Click()

    End Sub
    'Click cancel to hide userform
    Private Sub CommandButton2_Click()
    UserForm1.Hide
    End Sub
    'Add Tab name from ListBox 1 to ListBox 2
    Private Sub CommandButton3_Click()
    For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) = True Then ListBox2.AddItem ListBox1.List(i)
    Next i
    End Sub
    'Single Select from ListBox1
    Private Sub OptionButton1_Click()
    ListBox1.MultiSelect = 0
    ListBox2.MultiSelect = 0
    End Sub
    'Multiple Select from ListBox1
    Private Sub OptionButton2_Click()
    ListBox1.MultiSelect = 2
    ListBox2.MultiSelect = 2
    End Sub

    'Select worksheets to populate Auto-load worksheet
    Private Sub UserForm_Initialize()
    For Each ws In ThisWorkbook.Worksheets
    ListBox1.AddItem (ws.Name)
    Next ws
    End Sub
    'Remove item from ListBox 2
    Private Sub CommandButton4_Click()
    counter = 0
    For i = 0 To ListBox2.ListCount - 1
    If ListBox2.Selected(i - counter) Then
    ListBox2.RemoveItem (i - counter)
    counter = counter + 1
    End If
    Next i
    End Sub

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Unhide cells and columns in selected tabs

    Please use code tags around submitted code, it makes it much easier to see.

    In response, your code doesn't really help much as the responses you were given should solve your problem. I recommend submitting your actual workbook. There is probably some detail causing the issue which you are not able to observe and report.

  8. #8
    Registered User
    Join Date
    08-02-2015
    Location
    Newcastle, England
    MS-Off Ver
    2010
    Posts
    37

    Re: Unhide cells and columns in selected tabs

    I've managed to solve this, see code below for anyone who might be having the same problem - thanks for the help all.

    Please Login or Register  to view this content.
    Last edited by VBANovice46; 08-06-2015 at 02:36 PM. Reason: Adding code tags

+ 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. Apply a hide/unhide macro to all selected tabs
    By eric_be in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-22-2014, 08:50 AM
  2. [SOLVED] hide unhide columns with selected cells change font size
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-21-2014, 10:17 AM
  3. Hide and unhide columns based on value of 0 or 1 (respectively) in cells G1:LG1
    By cplawren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2012, 01:58 AM
  4. To unhide columns depending on which dropdown is selected
    By Biffa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2012, 01:21 PM
  5. Using checkboxes on summary sheet to name tabs and hide/unhide tabs
    By eew2201 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2012, 06:13 PM
  6. Unhide all tabs?
    By 1940LaSalle in forum Excel General
    Replies: 2
    Last Post: 02-25-2011, 09:41 AM
  7. Hide/Unhide Tabs VBA
    By JIBG in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-20-2007, 03:08 AM

Tags for this Thread

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