+ Reply to Thread
Results 1 to 7 of 7

Use variables to hide rows or collumns

  1. #1
    Registered User
    Join Date
    10-03-2014
    Location
    Phoenix, Arizona
    MS-Off Ver
    2010
    Posts
    13

    Use variables to hide rows or collumns

    Anybody know how to use variables in the place of [10:70]?
    When I try to use variable here it crashes.


    [10:70].EntireRow.Hidden = True 'Hide All Rows from 10-70

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Use variables to hide rows or collumns

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Use variables to hide rows or collumns

    Have you tried

    Rows("10:70").Select
    Selection.EntireRow.Hidden = True
    Happy with my advice? Click on the * reputation button below

  4. #4
    Registered User
    Join Date
    10-03-2014
    Location
    Phoenix, Arizona
    MS-Off Ver
    2010
    Posts
    13

    Re: Use variables to hide rows or collumns

    Shg:
    Hmmm... this didn't seem to work
    Heres the full code below, im fighting the formidable unhidden objects glitch in Excel 2010 and found a fix in blue below.
    Just trying to clean up a little bit of redundancy in the code by using loops and variables.
    The code shown in red is the last bit I need to use variables for, currently it is a manual input. Tried your suggestion, but it doesn't seem to work.


    Private Sub CheckBoxSMT_Click()

    Dim i As Long
    Dim ChkStart As Integer
    Dim ChkFinish As Integer
    Dim RowStart As Long
    Dim RowFinish As Long

    ChkStart = 1
    ChkFinish = 61
    RowStart = 10
    RowFinish = 70

    'Checkboxes: 1-61
    'Rows: 10-70

    If CheckBoxSMT = True Then
    For i = ChkStart To ChkFinish
    With ActiveSheet.Shapes("CheckBox" & i)
    .Visible = True
    End With
    Next
    [10:70].EntireRow.Hidden = False 'Unhide All
    'Rows(RowStart & ":" & RowFinish).Hidden = True
    Else:
    For i = ChkStart To ChkFinish
    With ActiveSheet.Shapes("CheckBox" & i)
    .Visible = False
    End With
    Next
    [10:70].EntireRow.Hidden = True 'Hide All
    'Rows(RowStart & ":" & RowFinish).Hidden = True
    End If

    For i = ChkStart To ChkFinish 'Reset Checkbox Position (Bug fix)
    With ActiveSheet.Shapes("CheckBox" & i)
    .Top = Range("G" & i + RowFinish - ChkFinish).Top
    End With
    Next


    End Sub

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Use variables to hide rows or collumns

    It worked fine for me. Did you try it standalone as I wrote it on a clean worksheet?

  6. #6
    Registered User
    Join Date
    10-03-2014
    Location
    Phoenix, Arizona
    MS-Off Ver
    2010
    Posts
    13

    Re: Use variables to hide rows or collumns

    Correction, this has been confirmed as a working solution to the problem.
    Thank you shg. Good job.

    Rows(RowStart & ":" & RowFinish).Hidden = True

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Use variables to hide rows or collumns

    You're welcome.

+ 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. Create Macro that will 'hide" rows that have no variables in column C
    By BAWILS in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-04-2013, 10:28 PM
  2. [SOLVED] Hide rows based on variables that are based on formulas
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2012, 06:21 AM
  3. Rows/collumns freeze - Removing black line
    By kayard in forum Excel General
    Replies: 0
    Last Post: 12-15-2011, 12:48 PM
  4. switching rows & collumns
    By littlewaywelt in forum Excel General
    Replies: 1
    Last Post: 12-02-2005, 12:50 PM
  5. [SOLVED] Collumns and rows
    By smintey in forum Excel General
    Replies: 3
    Last Post: 02-15-2005, 02:06 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