VBA: how to hide rows if a cell contains a certain textMove rows to new sheets in excelHow can I edit this...

The Ohm's law calculations of the parts do not agree with the whole

What can I do if someone tampers with my SSH public key?

Make me a metasequence

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Are small insurances worth it

Difference between 'stomach' and 'uterus'

Is every open circuit a capacitor?

Find maximum of the output from reduce

Book about a time-travel war fought by computers

Is divide-by-zero a security vulnerability?

Correct physics behind the colors on CD (compact disc)?

What is the meaning of "notice to quit at once" and "Lotty points”

Can an earth elemental drown/bury its opponent underground using earth glide?

Where is the fallacy here?

What is better: yes / no radio, or simple checkbox?

Wardrobe above a wall with fuse boxes

Where is this quote about overcoming the impossible said in "Interstellar"?

Quitting employee has privileged access to critical information

3.5% Interest Student Loan or use all of my savings on Tuition?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

The need of reserving one's ability in job interviews

Why doesn't "adolescent" take any articles in "listen to adolescent agonising"?

Sometimes a banana is just a banana

Levi-Civita symbol: 3D matrix



VBA: how to hide rows if a cell contains a certain text


Move rows to new sheets in excelHow can I edit this macro to loop through the results?VBA Code for changing background text for any text within a cellExcel VBA User Form option buttonsNot Inserting new records instead it updates the last record in Ms access vbavba error 1004 method intersect of object _global failedExcel VBA: Creating Hyperlinks Type MismatchHide and unhide rows dependent upon pull down listExcel VBA - View Hide specific rows depending on value in another rowcommand button execute copy and paste of worksheets into a new workbook and then automatically runs a macro in the new worksheets













0















I am using Excel 2013. I am new to VBA. I found a code that would simply hide 2 rows (36 and 37) if my cell N39 is equal to "Passed"



I found that code but I receive the message "ambiguous name detected "Worksheet_Change"



Private Sub Worksheet_Change(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False

End If
End Sub


so I tried the name of my worksheet but it does nothing



Private Sub NRF(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub


Could it be because I have another code above?



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim celltxt As String
celltxt = ActiveSheet.Range("E39").Text
If InStr(1, celltxt, "P670-Staffing") Then
MsgBox "Add the job title and type of hire in the description cell - column H" & vbNewLine & vbNewLine & "If this is a new position, please obtain your HRBP's approval"
End If
End Sub


Any idea of what I am doing wrong?










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    I'm voting to close this question as off-topic because OP has a typo "ows" instead of "Rows" in his code. Question is therefore unlikely to be useful for future readers.

    – DavidPostill
    Apr 14 '16 at 8:07











  • I corrected the typo and still have the same error message

    – BardonE
    Apr 15 '16 at 14:43











  • You can't have two functions with the same name and parameters Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 14:55













  • I removed the previous code and it works. How could it make it work with the other code?

    – BardonE
    Apr 15 '16 at 14:58













  • There is nothing calling NRF. Worksheet_Change is an event function that is called by Excel when the worksheet changes. You need to put all of the code inside Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 15:01


















0















I am using Excel 2013. I am new to VBA. I found a code that would simply hide 2 rows (36 and 37) if my cell N39 is equal to "Passed"



I found that code but I receive the message "ambiguous name detected "Worksheet_Change"



Private Sub Worksheet_Change(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False

End If
End Sub


so I tried the name of my worksheet but it does nothing



Private Sub NRF(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub


Could it be because I have another code above?



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim celltxt As String
celltxt = ActiveSheet.Range("E39").Text
If InStr(1, celltxt, "P670-Staffing") Then
MsgBox "Add the job title and type of hire in the description cell - column H" & vbNewLine & vbNewLine & "If this is a new position, please obtain your HRBP's approval"
End If
End Sub


Any idea of what I am doing wrong?










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    I'm voting to close this question as off-topic because OP has a typo "ows" instead of "Rows" in his code. Question is therefore unlikely to be useful for future readers.

    – DavidPostill
    Apr 14 '16 at 8:07











  • I corrected the typo and still have the same error message

    – BardonE
    Apr 15 '16 at 14:43











  • You can't have two functions with the same name and parameters Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 14:55













  • I removed the previous code and it works. How could it make it work with the other code?

    – BardonE
    Apr 15 '16 at 14:58













  • There is nothing calling NRF. Worksheet_Change is an event function that is called by Excel when the worksheet changes. You need to put all of the code inside Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 15:01
















0












0








0








I am using Excel 2013. I am new to VBA. I found a code that would simply hide 2 rows (36 and 37) if my cell N39 is equal to "Passed"



I found that code but I receive the message "ambiguous name detected "Worksheet_Change"



Private Sub Worksheet_Change(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False

End If
End Sub


so I tried the name of my worksheet but it does nothing



Private Sub NRF(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub


Could it be because I have another code above?



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim celltxt As String
celltxt = ActiveSheet.Range("E39").Text
If InStr(1, celltxt, "P670-Staffing") Then
MsgBox "Add the job title and type of hire in the description cell - column H" & vbNewLine & vbNewLine & "If this is a new position, please obtain your HRBP's approval"
End If
End Sub


Any idea of what I am doing wrong?










share|improve this question
















I am using Excel 2013. I am new to VBA. I found a code that would simply hide 2 rows (36 and 37) if my cell N39 is equal to "Passed"



I found that code but I receive the message "ambiguous name detected "Worksheet_Change"



Private Sub Worksheet_Change(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False

End If
End Sub


so I tried the name of my worksheet but it does nothing



Private Sub NRF(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub


Could it be because I have another code above?



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim celltxt As String
celltxt = ActiveSheet.Range("E39").Text
If InStr(1, celltxt, "P670-Staffing") Then
MsgBox "Add the job title and type of hire in the description cell - column H" & vbNewLine & vbNewLine & "If this is a new position, please obtain your HRBP's approval"
End If
End Sub


Any idea of what I am doing wrong?







microsoft-excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 '16 at 14:54









DavidPostill

106k26228263




106k26228263










asked Apr 12 '16 at 22:06









BardonEBardonE

63




63





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1





    I'm voting to close this question as off-topic because OP has a typo "ows" instead of "Rows" in his code. Question is therefore unlikely to be useful for future readers.

    – DavidPostill
    Apr 14 '16 at 8:07











  • I corrected the typo and still have the same error message

    – BardonE
    Apr 15 '16 at 14:43











  • You can't have two functions with the same name and parameters Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 14:55













  • I removed the previous code and it works. How could it make it work with the other code?

    – BardonE
    Apr 15 '16 at 14:58













  • There is nothing calling NRF. Worksheet_Change is an event function that is called by Excel when the worksheet changes. You need to put all of the code inside Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 15:01
















  • 1





    I'm voting to close this question as off-topic because OP has a typo "ows" instead of "Rows" in his code. Question is therefore unlikely to be useful for future readers.

    – DavidPostill
    Apr 14 '16 at 8:07











  • I corrected the typo and still have the same error message

    – BardonE
    Apr 15 '16 at 14:43











  • You can't have two functions with the same name and parameters Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 14:55













  • I removed the previous code and it works. How could it make it work with the other code?

    – BardonE
    Apr 15 '16 at 14:58













  • There is nothing calling NRF. Worksheet_Change is an event function that is called by Excel when the worksheet changes. You need to put all of the code inside Worksheet_Change

    – DavidPostill
    Apr 15 '16 at 15:01










1




1





I'm voting to close this question as off-topic because OP has a typo "ows" instead of "Rows" in his code. Question is therefore unlikely to be useful for future readers.

– DavidPostill
Apr 14 '16 at 8:07





I'm voting to close this question as off-topic because OP has a typo "ows" instead of "Rows" in his code. Question is therefore unlikely to be useful for future readers.

– DavidPostill
Apr 14 '16 at 8:07













I corrected the typo and still have the same error message

– BardonE
Apr 15 '16 at 14:43





I corrected the typo and still have the same error message

– BardonE
Apr 15 '16 at 14:43













You can't have two functions with the same name and parameters Worksheet_Change

– DavidPostill
Apr 15 '16 at 14:55







You can't have two functions with the same name and parameters Worksheet_Change

– DavidPostill
Apr 15 '16 at 14:55















I removed the previous code and it works. How could it make it work with the other code?

– BardonE
Apr 15 '16 at 14:58







I removed the previous code and it works. How could it make it work with the other code?

– BardonE
Apr 15 '16 at 14:58















There is nothing calling NRF. Worksheet_Change is an event function that is called by Excel when the worksheet changes. You need to put all of the code inside Worksheet_Change

– DavidPostill
Apr 15 '16 at 15:01







There is nothing calling NRF. Worksheet_Change is an event function that is called by Excel when the worksheet changes. You need to put all of the code inside Worksheet_Change

– DavidPostill
Apr 15 '16 at 15:01












2 Answers
2






active

oldest

votes


















0














This code works on my machine (Windows 7 x64, Excel 2016):



Private Sub Worksheet_Change(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub


I think the misspelling of "Rows" as "ows" may have something to do with it. And I also had to remove the extraneous linefeed to get it to work.






share|improve this answer


























  • I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

    – BardonE
    Apr 15 '16 at 14:52











  • Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

    – BillDOe
    Apr 15 '16 at 18:51



















0














Any idea of what I am doing wrong?




I found that code but I receive the message "ambiguous name detected "Worksheet_Change"




You can't have two functions with the same name and parameters Worksheet_Change.




I removed the previous code and it works. How could it make it work with the other code?




You need to put all of the code inside a single Worksheet_Change function.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1064755%2fvba-how-to-hide-rows-if-a-cell-contains-a-certain-text%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This code works on my machine (Windows 7 x64, Excel 2016):



    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("N39").Value = "Passed" Then
    Rows("36:37").EntireRow.Hidden = True
    ElseIf Range("N39").Value = "Failed" Then
    Rows("36:37").EntireRow.Hidden = False
    End If
    End Sub


    I think the misspelling of "Rows" as "ows" may have something to do with it. And I also had to remove the extraneous linefeed to get it to work.






    share|improve this answer


























    • I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

      – BardonE
      Apr 15 '16 at 14:52











    • Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

      – BillDOe
      Apr 15 '16 at 18:51
















    0














    This code works on my machine (Windows 7 x64, Excel 2016):



    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("N39").Value = "Passed" Then
    Rows("36:37").EntireRow.Hidden = True
    ElseIf Range("N39").Value = "Failed" Then
    Rows("36:37").EntireRow.Hidden = False
    End If
    End Sub


    I think the misspelling of "Rows" as "ows" may have something to do with it. And I also had to remove the extraneous linefeed to get it to work.






    share|improve this answer


























    • I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

      – BardonE
      Apr 15 '16 at 14:52











    • Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

      – BillDOe
      Apr 15 '16 at 18:51














    0












    0








    0







    This code works on my machine (Windows 7 x64, Excel 2016):



    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("N39").Value = "Passed" Then
    Rows("36:37").EntireRow.Hidden = True
    ElseIf Range("N39").Value = "Failed" Then
    Rows("36:37").EntireRow.Hidden = False
    End If
    End Sub


    I think the misspelling of "Rows" as "ows" may have something to do with it. And I also had to remove the extraneous linefeed to get it to work.






    share|improve this answer















    This code works on my machine (Windows 7 x64, Excel 2016):



    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("N39").Value = "Passed" Then
    Rows("36:37").EntireRow.Hidden = True
    ElseIf Range("N39").Value = "Failed" Then
    Rows("36:37").EntireRow.Hidden = False
    End If
    End Sub


    I think the misspelling of "Rows" as "ows" may have something to do with it. And I also had to remove the extraneous linefeed to get it to work.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 13 '16 at 14:45









    Raystafarian

    19.5k105089




    19.5k105089










    answered Apr 13 '16 at 1:17









    BillDOeBillDOe

    9762828




    9762828













    • I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

      – BardonE
      Apr 15 '16 at 14:52











    • Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

      – BillDOe
      Apr 15 '16 at 18:51



















    • I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

      – BardonE
      Apr 15 '16 at 14:52











    • Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

      – BillDOe
      Apr 15 '16 at 18:51

















    I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

    – BardonE
    Apr 15 '16 at 14:52





    I copied and pasted your code but still have the same error message. I thought it could be the code I had prior but even if I delete the prior code, it does not work. Any suggestion?

    – BardonE
    Apr 15 '16 at 14:52













    Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

    – BillDOe
    Apr 15 '16 at 18:51





    Do you have this code attached to the sheet or as a separate module? It should be attached to the sheet.

    – BillDOe
    Apr 15 '16 at 18:51













    0














    Any idea of what I am doing wrong?




    I found that code but I receive the message "ambiguous name detected "Worksheet_Change"




    You can't have two functions with the same name and parameters Worksheet_Change.




    I removed the previous code and it works. How could it make it work with the other code?




    You need to put all of the code inside a single Worksheet_Change function.






    share|improve this answer




























      0














      Any idea of what I am doing wrong?




      I found that code but I receive the message "ambiguous name detected "Worksheet_Change"




      You can't have two functions with the same name and parameters Worksheet_Change.




      I removed the previous code and it works. How could it make it work with the other code?




      You need to put all of the code inside a single Worksheet_Change function.






      share|improve this answer


























        0












        0








        0







        Any idea of what I am doing wrong?




        I found that code but I receive the message "ambiguous name detected "Worksheet_Change"




        You can't have two functions with the same name and parameters Worksheet_Change.




        I removed the previous code and it works. How could it make it work with the other code?




        You need to put all of the code inside a single Worksheet_Change function.






        share|improve this answer













        Any idea of what I am doing wrong?




        I found that code but I receive the message "ambiguous name detected "Worksheet_Change"




        You can't have two functions with the same name and parameters Worksheet_Change.




        I removed the previous code and it works. How could it make it work with the other code?




        You need to put all of the code inside a single Worksheet_Change function.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 15 '16 at 15:33









        DavidPostillDavidPostill

        106k26228263




        106k26228263






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1064755%2fvba-how-to-hide-rows-if-a-cell-contains-a-certain-text%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...