Closed Thread
Results 1 to 5 of 5

VBA Coding Help - Newbie

Hybrid View

stockjc VBA Coding Help - Newbie 08-28-2012, 06:12 AM
Andrew-R Re: VBA Coding Help - Newbie 08-28-2012, 06:17 AM
NickyC Re: VBA Coding Help - Newbie 08-28-2012, 06:18 AM
stockjc Re: VBA Coding Help - Newbie 08-28-2012, 06:56 AM
arlu1201 Re: VBA Coding Help - Newbie 08-28-2012, 06:58 AM
  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    VBA Coding Help - Newbie

    Hi,

    Im looking for some assitance in writing some code. I am very new at this so sorry if my question seems basic and easy but I have no idea where to start. Basically I am looking at writing code which does the following:

    If A1 = 1 then hide rows 3:10, 11, 15, 19, 20:50 etc

    If A1 = 2 then hide rows 3:10, 15, 29:52, 82

    If A1 = 3 then hide rows 3:20, 95

    If A1 = 4 then hide rows 8:10, 12, 14, 16, 18, 20, 22, 24:60

    Now im able to get the first code which I have written as:

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Range("A1") = 1 Then
    Rows("3:10").EntireRow.Hidden = True
    Rows("11").EntireRow.Hidden = True
    Rows("15").EntireRow.Hidden = True
    Rows("19").EntireRow.Hidden = True
    Rows("20:50").EntireRow.Hidden = True


    End If

    End Sub

    But as soon as I write the same again chaning 1 to 2, it seems to contridict itself and does nothing. Any help would be greatly appreciated as I really dont know what im doing lol.

    Thanks

    James

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: VBA Coding Help - Newbie

    Hi James and welcome to the forum.

    What you're asking for isn't hard, but before anybody jumps in could I ask that you have a read of the forum rules and give your thread a title which complies with rule 1, and put code tags around the VBA you've posted, as per rule #3.

    Thanks

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: VBA Coding Help - Newbie

    hi
    you may need to unhide all rows before hiding selected ones with your macro - otherwise previously hidden rows will stay hidden

    Andrew - my apologies for posting without refreshing - i didn't see your post

  4. #4
    Registered User
    Join Date
    08-28-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA Coding Help - Newbie

    Hi Andrew-R, Apologises as I didnt read the forum rules. Have reposted this thread adhering to the rules.

    I hope this is ok.

    Sorry again,

    James

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Coding Help - Newbie

    James,

    All you had to do was edit the thread title of the 1st post in this thread, not create a duplicate thread.

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread. http://www.excelforum.com/excel-gene...ll-result.html

    Thread Closed.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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