+ Reply to Thread
Results 1 to 5 of 5

Not understanding the macro issue

Hybrid View

  1. #1
    Registered User
    Join Date
    09-24-2012
    Location
    DSM
    MS-Off Ver
    Excel 2007
    Posts
    5

    Not understanding the macro issue

    So I am working with a similar questionaire/interview list as attached. I am using Excel 2007 and I need to get a macro to populate certain rows based off of a cell that has text of YES or NO.

    I managed to get the FIRST question to work with the macro- my issue is don't know what I am doing now.

    So I have (as you can see) multiple sets of hidden rows. (most are grouped for markers right now)

    I need for the cell that says YES or NO to either keep a row hidden or show a row but i need it to do it multiple times. (with different questions)

    Here is an example:

    I have cell C35 with Yes- then row 36 stays hidden. If cell C35 says NO- then row 36 shows. This part I have down.

    Now I want to continue adding things- for instance- if cell C43 says NO- then I want the rows 44-48 to stay hidden. If cell C43 says YES- I would like it to SHOW rows 44-48.

    I hope I am making this clear? My issue is that I am CLUELESS with macros and the script. I am attempting to teach myself/learn from others on the forums. Any help would be appreciated. I am attaching my .xlsm.

    PLEASE HELP! I don't understand if I can put more subs under one event or if I have to make a new event- or if thats possible on one sheet. I am just clueless. Any tips/tricks are much appreciated. I just can't seem to find what I am looking for when I search for what I need!!

    Thank you for your time Please don't be too harsh with my lack of knowledge! lol.











    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
        If Not Intersect(Target, Range("C35")) Is Nothing Then
            Rows(36).Hidden = (Target.Value = ("Yes")) + (Target.Value = (""))
    
        End If
    
    End Sub
        Sub show()
       With Range("c35").EntireRow
    
            Rows(36).ShowDetail = (Target.Value = "No")
        End
        
    End Sub
        
       
        If Not Intersect(Target, Range("C44")) Is Nothing Then
            Rows(44 - 48).Hidden = (Target.Value = ("No")) + (Target.Value = (""))
    
        End If
       Sub show1()
      With Range("c44").EntireRow
    
            Rows(44 - 48).ShowDetail = (Target.Value = "Yes")
        End
        
    End Sub
    Attached Files Attached Files
    Last edited by Cutter; 10-20-2012 at 06:11 PM. Reason: Added code tags

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Not understanding the macro issue

    First of all, good on you for giving it a go. That is the best way to learn.

    Try using this approach. Delete everything you have got and use this code. You should be able to work out how to expand from here
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
        Select Case Target
            Case Is = Range("C35")
                If Proper(Target.Value) = "Yes" Then Rows(36).EntireRow.Hidden = True Else Rows(36).EntireRow.Hidden = False
            Case Is = Range("C43")
                If Proper(Target.Value) = "Yes" Then Rows("44:48").EntireRow.Hidden = True Else Rows("44:48").EntireRow.Hidden = False
        End Select
    End Sub

  3. #3
    Registered User
    Join Date
    09-24-2012
    Location
    DSM
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Not understanding the macro issue

    You are awesome! lol. Now what am I doing wrong? I can't get it to work

  4. #4
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Not understanding the macro issue

    here is is in the sheet
    Attached Files Attached Files

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Not understanding the macro issue

    @ nawilliams62

    Welcome to the forum.

    Please notice that [CODE] tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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