+ Reply to Thread
Results 1 to 8 of 8

Hidding rows by using VBA

  1. #1
    Registered User
    Join Date
    02-28-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    19

    Post Hidding rows by using VBA

    I am using Excel 2010 and I am trying to hide the rows# 10 to 12 in Sheet6 and it is working perfect by clicking on radio button

    Please Login or Register  to view this content.
    Now i also want to hide two more rows in Sheet7 by using below snipet but it doesn't work, Kindly help in below code.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Hidding rows by using VBA

    This:
    Please Login or Register  to view this content.
    or this;
    Please Login or Register  to view this content.
    Last edited by Jim885; 03-17-2014 at 08:43 AM.
    If I helped in any way, please click the star

  3. #3
    Registered User
    Join Date
    02-28-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    19

    Re: Hidding rows by using VBA

    Quote Originally Posted by Jim885 View Post
    This:
    Please Login or Register  to view this content.
    or this;
    Please Login or Register  to view this content.
    Mr. Jim
    I tried both snippets but it is giving me RunTime error 9 "Script out of range"

  4. #4
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Hidding rows by using VBA

    Quote Originally Posted by crimzon View Post
    Mr. Jim
    I tried both snippets but it is giving me RunTime error 9 "Script out of range"
    Is the other sheet actually named Sheet7 or does it have a different name?
    If it has a different name, change "Sheet7" in the code to the actual name of the sheet, "NameofSheet"
    Remember to use the quotes.
    Also, the second code I gave you would be the preferred method.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: Hidding rows by using VBA

    Hi crimson,

    This looks like a problem of scope to me. If you have your code behind a worksheet it works on that sheet. But if you have the code behind a "module" it will work across all worksheets. Read:
    http://www.excel-easy.com/vba/exampl...ble-scope.html

    Put your code in a Module and see if it works.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Hidding rows by using VBA

    This works for me:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-28-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    19

    Re: Hidding rows by using VBA

    Quote Originally Posted by JOHN H. DAVIS View Post
    This works for me:

    Please Login or Register  to view this content.
    I tried on new workbook and it works fine. Thank Mr. John

  8. #8
    Registered User
    Join Date
    02-28-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    19

    Re: Hidding rows by using VBA

    Quote Originally Posted by MarvinP View Post
    Hi crimson,

    This looks like a problem of scope to me. If you have your code behind a worksheet it works on that sheet. But if you have the code behind a "module" it will work across all worksheets. Read:
    http://www.excel-easy.com/vba/exampl...ble-scope.html

    Put your code in a Module and see if it works.
    Thanks, this is also helpful to understand the concept of varible scope in VB language.
    Can you kindly suggest me another link to study VB language for beginners?

  9. #9
    Registered User
    Join Date
    02-28-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    19

    Re: Hidding rows by using VBA

    Quote Originally Posted by MarvinP View Post
    Hi crimson,

    This looks like a problem of scope to me. If you have your code behind a worksheet it works on that sheet. But if you have the code behind a "module" it will work across all worksheets. Read:
    http://www.excel-easy.com/vba/exampl...ble-scope.html

    Put your code in a Module and see if it works.
    Thanks, this is also helpful to understand the concept of varible scope in VB language.
    Can you kindly suggest me another link to study VB language for beginners?

+ 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] Need help hidding rows by looking up a list of criterias from 2 sheets
    By havenzhiv in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2012, 10:16 AM
  2. Hidding rows at print that contain no data
    By tvwhome in forum Excel General
    Replies: 2
    Last Post: 07-29-2010, 06:04 AM
  3. Hidding Unused Rows based on column value
    By mashley in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-18-2010, 01:51 PM
  4. hidding rows with checkboxes and coping visible rows to another sheet
    By aviflux in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-15-2008, 09:35 AM
  5. Hidding Rows
    By Sam I Am in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2007, 07:16 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