+ Reply to Thread
Results 1 to 14 of 14

Run macro everytime cell content changes

Hybrid View

minn Run macro everytime cell... 01-15-2008, 07:28 AM
ashishprem goto macro window by pressing... 01-15-2008, 08:35 AM
minn Thanks, i have now tried... 01-15-2008, 10:36 AM
chucklod Move the macro 01-15-2008, 12:07 PM
minn Hi, Tried that, no luck. ... 01-15-2008, 12:13 PM
  1. #1
    Registered User
    Join Date
    01-13-2008
    Posts
    19

    Run macro everytime cell content changes

    I want a macro to run everytime the value in say cell D6 changes.

    Anyone know how to do this?

    Many Thanks

  2. #2
    Registered User
    Join Date
    02-13-2006
    Posts
    46
    goto macro window by pressing alt+F11
    Select the sheet from left panel. there will be two drop down. from the left drop down select worksheet and from right drop down list select the event change.

    to access rows and cols you can use following

    Target.Worksheet.Cells(1, 1) 
    Target.Row 
    Target.Column
    hope it helps..

    Ashish
    Last edited by VBA Noob; 01-15-2008 at 02:31 PM.

  3. #3
    Registered User
    Join Date
    01-13-2008
    Posts
    19
    Thanks, i have now tried using this:

    Private Sub Worksheet_Change(ByVal Target As Range)
          
                  If Target.Address = "$D$5" Then
                           Call Module3.View_All_Risks
                  End If
     
    End Sub
    The problem now is that the macro does not fire when the value in cell D5 is changed. The macro run on its own works fine.

    Any ideas?

    Thanks!

  4. #4
    Registered User
    Join Date
    01-07-2008
    Posts
    38

    Move the macro

    Hi,

    You need to make sure the macro (which is an "event handler") is located in the code module for the worksheet it applies to.

    Right click the worksheet (e.g., Sheet1) in the Project explorer and select "View Code". Copy the macro to the page that brings up. Then it should work any time the value in cell D5 is changed.

    Chuck L

  5. #5
    Registered User
    Join Date
    01-13-2008
    Posts
    19
    Hi,

    Tried that, no luck.

    Here is the macro that I want to run:

    Sub View_DatabyProjID()
    
    Sheets("Actions Register").Select
    Call Module7.RemoveFilter
    Call Module7.AddFilter_actions
    Selection.AutoFilter Field:=2, Criteria1:=Worksheets("Overview").Range("D6")
    
    Sheets("Risks Register").Select 'goto the Risks Register worksheet
    Call Module7.RemoveFilter 'remove all current filters
    Call Module7.AddFilter_Risks 'reapply the filter
    Selection.AutoFilter Field:=2, Criteria1:=Worksheets("Overview").Range("D6") 'filter by risks that correspond to the projectID that appears in worksheet 'Overview' and cell D6
    
    
    Sheets("Issues Register").Select
    Call Module7.RemoveFilter
    Call Module7.AddFilter_Issues
    Selection.AutoFilter Field:=2, Criteria1:=Worksheets("Overview").Range("D6")
    
    Sheets("Overview").Select
    
    End Sub
    Thanks

  6. #6
    Registered User
    Join Date
    01-13-2008
    Posts
    19
    I have just realised that the problem is because the cell D5 where i want changed values to be detected is a validation list where values are changed via a drop down list.

    I tested suing another cell where this was not the case.

    Does anyone therefore know how to run a macro when the value in a cell that uses a validation list is changed?

    Many Thanks

+ 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