+ Reply to Thread
Results 1 to 4 of 4

Change Event (can someone check this code?)

  1. #1
    Registered User
    Join Date
    07-14-2004
    Posts
    22

    Change Event (can someone check this code?)

    Why does this not work?

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
    If Target.Address = 1 Then
    UserForm1.Show
    Else
    If Target.Address = 2 Then
    UserForm2.Show
    Else
    End If
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Your If statements are not structured correctly.

    What are you actually tring to test for?

    In your first If you are looking to see if the Target has the Address $A$1.

    Then you are looking to see if the Address is 1 or 2.

    A range address is not going to be 1 or 2, are you actually trying to test the value in cell A1?
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-14-2004
    Posts
    22
    I am trying to limit code to triggering only when a certain cell is changed. When that cell is changed I want other cells to be affected by the code.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Well the code I posted should only be triggered when A1 is changed.

    Obviously change that for your own needs.

+ 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