Results 1 to 3 of 3

Workaround for recognizing reference cell changes in Change_Event

Threaded View

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    37

    Workaround for recognizing reference cell changes in Change_Event

    Hello,

    I have a workbook that utilizes a Worksheet_Change Event to erase relevant cells in the same row. However, it doesn't work since the cells that the Worksheet_Change Event runs on are actually reference cells to another workbook in another department.

    I created a macro to "click + enter" every single cell in column B so that the Worksheet_Change Event runs. This works perfectly fine but takes too much time to run for it to be useful (My actual workbook has hundreds of rows). However, if you take a look at the attached file, wouldn't it be possible to create a code that simply finds each cell with a value in column D, and then make it automatically "click + enter" the cell in column B? This seems like a viable solution since there will usually only be 1-5 rows that would need to be activated. This code could then also run on column E & F.

    Change Event that I need to run on reference cells in column B:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Not Intersect(Target, Columns("A:A")) Is Nothing Then
        If Target.Value = "" Or Target.Value = 0 Then
            Application.EnableEvents = False
            Target.Offset(0, 1).Resize(1, 3).ClearContents
            Application.EnableEvents = True
        End If
    End If
    
    If Not Intersect(Target, Columns("B:D")) Is Nothing Then
        If Range("A" & Target.Row).Value = "" Then
            Application.EnableEvents = False
            Target.ClearContents
            Application.EnableEvents = True
        End If
    End If
            
    End Sub
    Current code I use to activate each cell in column B to make Worksheet_Change event run:
    Sub Clear_Blanks()
    
    Application.ScreenUpdating = False
    
    
        Range("B2").Select
        ActiveCell.FormulaR1C1 = _
            "=IF(Data!R[-5]C[-1]='Input Sheet'!RC[-1],Data!R[-5]C,"""")"
        Range("B3").Select
        ActiveCell.FormulaR1C1 = _
            "=IF(Data!R[-5]C[-1]='Input Sheet'!RC[-1],Data!R[-5]C,"""")"
        Range("B4").Select
    
    'This code continues until all cells in column B have been activated
    
    Application.ScreenUpdating = True
    
    End Sub
    Many thanks for your input!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Workaround for a circular reference
    By bibu in forum Excel General
    Replies: 2
    Last Post: 04-09-2014, 02:19 PM
  2. How to Trigger the Change_Event without actually changing the value of a cell
    By JamesGoulding85 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2013, 09:08 AM
  3. Can you change the Target reference in Change_Event sub???
    By JamesGoulding85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2013, 05:16 AM
  4. Circular Reference Workaround
    By macky1730 in forum Excel General
    Replies: 1
    Last Post: 11-01-2010, 08:51 PM
  5. Circular reference issue. Looking for workaround.
    By krutec in forum Excel General
    Replies: 2
    Last Post: 12-11-2009, 03:20 PM

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