+ Reply to Thread
Results 1 to 2 of 2

Private Sub Worksheet_Change

  1. #1
    Registered User
    Join Date
    02-14-2008
    Posts
    1

    Red face Please help!!!!!Private Sub Worksheet_Change

    Can someone help me!!!!!!!! Please!!!!!!!!! am a visual basic novice and am trying to building a calculator in excel using the “Worksheet_Change” code but unfortunately its not working properly. So, am seeking some advice…………

    What I want:

    • The code to perform is an automatic update once a cell has changes.
    Lets say when H3=Renewals,
    Hide some cells and go to H3 and don’t run the code again unless I type something other than Renewals
    It should also let me continue working with the worksheet cells (That’s my main problem the code runs over and over and over again and it doesn’t let me continue)

    The code that am using is:

    Private Sub Worksheet_Change(ByVal Target As Range)

    * First action I want the code to perform

    If Range("H3") = "RENEWALS" Then
    Range("b37").Select
    Sheets("COVER PAGE").Select
    Rows("37:43").Select
    Selection.EntireRow.Hidden = True
    Range("h3").Select
    Else
    Rows("37:43").Select
    Selection.EntireRow.Hidden = False
    Range("D7").Select
    End If

    * Code should stop here and let the user continue till the next if statement

    If Range("M26") = "Yes" Then
    Range("b76").Select
    Sheets("COVER PAGE").Select
    Rows("76:77").Select
    Selection.EntireRow.Hidden = False
    Range("D30").Select

    Else
    Rows("76:77").Select
    Selection.EntireRow.Hidden = True
    Range("D30").Select

    End If
    * Code should stop here and let the user continue till the next if statement

    If Range("M24") = "REVISED" Then
    Range("a55").Select
    Sheets("COVER PAGE").Select
    Rows("50:57").Select
    Selection.EntireRow.Hidden = False
    Rows("55:56").Select
    Selection.EntireRow.Hidden = True
    Rows("60:66").Select
    Selection.EntireRow.Hidden = True

    Range("d52").Select

    End If

    * Code should stop here and let the user continue till the next if statement

    'PRINEW SUPER CALCULATIONS
    If Range("M24") = "NEW" Then
    Range("a52").Select
    Sheets("COVER PAGE").Select
    Rows("50:57").Select
    Selection.EntireRow.Hidden = False
    'Hide Row
    Rows("53:54").Select
    Selection.EntireRow.Hidden = True
    'Hide
    Rows("60:66").Select
    Selection.EntireRow.Hidden = True

    ' SELECT CELLS AFTER HIDE....
    Sheets("COVER PAGE").Select
    Range("d52").Select

    End If
    * Code should stop here and let the user continue till the next if statement

    'VICSUPER CALCULATIONS
    If Range("M24") = "OTHER(Eg VICSUPER" Then
    Range("A62").Select
    Sheets("COVER PAGE").Select

    Rows("51:66").Select
    Selection.EntireRow.Hidden = False
    ' Hide
    Sheets("COVER PAGE").Select
    Rows("51:56").Select
    Selection.EntireRow.Hidden = True

    ' SELECT CELLS AFTER HIDE....
    Sheets("COVER PAGE").Select
    'Range("E62").Select

    End If

    * Code should stop here and let the user continue till the next if statement

    'SERB SUPER CALCULATIONS
    If Range("M24") = "SERB" Then
    Sheets("COVER PAGE").Select
    Rows("50:57").Select
    Selection.EntireRow.Hidden = False
    'Hide
    Rows("51:56").Select
    Selection.EntireRow.Hidden = True
    'Hide
    Rows("60:66").Select
    Selection.EntireRow.Hidden = True

    ' SELECT CELLS AFTER HIDE....
    Sheets("COVER PAGE").Select
    Range("c80").Select

    End If
    * Code should stop here and let the user continue till the next if statement

    End Sub

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Please read the forum rules and edit your post to WRAP your code.


    rylo

+ Reply to 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