+ Reply to Thread
Results 1 to 2 of 2

Hiding rows based on a user input box

Hybrid View

jshaw82 Hiding rows based on a user... 10-08-2013, 04:01 PM
stnkynts Re: Hiding rows based on a... 10-08-2013, 06:34 PM
  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Hiding rows based on a user input box

    Hi All,

    I've come up with the following bit of code whihch is to be used to hide rows based on a user input box:

    Sub RowHider()
    
        Dim s As String, k As Long
        
    Enterno:
        s = InputBox("Enter no of engineers to show (Upto 50)")
        If Not IsNumeric(s) Then GoTo Enterno
        
        endrow = 56
        If s = 50 Then
            Rows("6:57").Hidden = False
        ElseIf s > 50 Then GoTo Enterno
           
        Else
            Rows("6:57").Hidden = False
            Rows((s + 6):56).hidden = true
            
        End If
    End Sub
    The bit ive underline is the bit i'm struggling with. I basically want it to hide from the number the user has entered + 6 rows so if they enter 20 it would hide rows 26:56

    Can anyone help? Thanks in advance.

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

    Re: Hiding rows based on a user input box

    Try:

    Sub Row_Hider()
    Dim s As String
    
    Range("A6:A56").EntireRow.Hidden = False 'not sure if you want this in there
    
    Do
        s = Application.InputBox("Enter no of engineers to show (Upto 50)")
    Loop While Not IsNumeric(s) And Not IsNull(s)
    
    If s > 50 Then
        s = 50
    End If
    
    Range("A" & s + 6, "A56").EntireRow.Hidden = True
    
    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. Help Needed Hiding Rows & Columns Based On an Input [REWARD]
    By thesteve in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2013, 01:23 PM
  2. [SOLVED]Hide Rows and Columns Based on User Input
    By thesteve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 01:32 PM
  3. Macro to Copy Rows based on User Input
    By CharterJP in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 06:13 PM
  4. Automate formulated rows based on user input
    By G2S in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2012, 10:06 PM
  5. Delete rows based on user input
    By Militia in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-10-2009, 06:33 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