+ Reply to Thread
Results 1 to 6 of 6

How can I trick excel into thinking cell data has changed?

Hybrid View

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Question How can I trick excel into thinking cell data has changed?

    I have a macro that runs when a cell data changes and it works fine, however I want to have a button on the first sheet that will run this macro on every single page, i dont want to rewrite the whole crazy long macro from multiple pages into a button module, so i was thinking its easier if i just make excel think the data changed so it would run the macro to update it.

    Here is what I have, but it seems to not work for whatever reason:

    Sub FullUpdateTest()
    
     'Clear all traffic lights
            Sheets("Geräte, Einrichtungen..").Activate
            Range("G5:M300").Select
            Selection.ClearContents
            Sheets("Geräte, Einrichtungen..").Activate
            Range("E55:E300").Select
            Selection.ClearContents
            Sheets("Kalkulat. ALV").Activate
            Range("E4:E300").Select
            Selection.ClearContents
            Sheets("Dokumente").Activate
            Range("E4:E300").Select
            Selection.ClearContents
            Sheets("Instandhaltungskosten").Activate
            Range("E4:E300").Select
            Selection.ClearContents
    
    
    
    StartRow = 2
    EndRow = 300
    
    
    For RowCnt = StartRow To EndRow
    
    SheetToActivate = "Geräte, Einrichtungen.."
    Sheets(SheetToActivate).Activate
    
    TempInfo = Cells(RowCnt, 2)
    Range(Cells(RowCnt, "2")).Select
    Selection.ClearConents
    Cells(RowCnt, 2) = "74893740141"
    Cells(RowCnt, 2) = TempInfo
    
    SheetToActivate = "Kalkulat. ALV"
    Sheets(SheetToActivate).Activate
    
    TempInfo = Cells(RowCnt, 2)
    Range(Cells(RowCnt, "2")).Select
    Selection.ClearConents
    Cells(RowCnt, 2) = "74893740141"
    Cells(RowCnt, 2) = TempInfo
    
    SheetToActivate = "Dokumente"
    Sheets(SheetToActivate).Activate
    
    TempInfo = Cells(RowCnt, 2)
    Range(Cells(RowCnt, "2")).Select
    Selection.ClearConents
    Cells(RowCnt, 2) = "74893740141"
    Cells(RowCnt, 2) = TempInfo
    
    SheetToActivate = "Instandhaltungskosten"
    Sheets(SheetToActivate).Activate
    
    TempInfo = Cells(RowCnt, 2)
    Range(Cells(RowCnt, "2")).Select
    Selection.ClearConents
    Cells(RowCnt, 2) = "74893740141"
    Cells(RowCnt, 2) = TempInfo
    
    
    
    Next RowCnt
    
    
    
    End Sub

  2. #2
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How can I trick excel into thinking cell data has changed?

    This is the code i have on 3 of the 4 tabs (the code on the 4th is a lot longer and more complicated, and it seems to be the same issue, just giving as example).

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    
        Dim KeyCells As Range
        Set KeyCells = Range("B5:B300")
    
        If Not Application.Intersect(KeyCells, Range(Target.Address)) _
            Is Nothing Then
    
            'Variables
            TodaysDate = Date
            LastUpdateDate = ActiveSheet.Cells(Target.Row, Target.Column)
            Interval = "0"
            Interval = ActiveSheet.Cells(Target.Row, Target.Column + 1)
            NextUpdateDate = DateAdd("d", Interval, LastUpdateDate)
            YellowDate = DateAdd("d", -14, NextUpdateDate)
        
        'Red
        If TodaysDate >= NextUpdateDate Then
            ActiveSheet.Cells(Target.Row, Target.Column + 3) = "1"
        End If
        
        'Green
        If (TodaysDate < YellowDate) Then
            ActiveSheet.Cells(Target.Row, Target.Column + 3) = "3"
        End If
        
         'Yellow
        If (TodaysDate > YellowDate) And (TodaysDate < NextUpdateDate) Then
            ActiveSheet.Cells(Target.Row, Target.Column + 3) = "2"
        End If
        
         If ActiveSheet.Cells(Target.Row, Target.Column).Value = "" Then
            ActiveSheet.Cells(Target.Row, Target.Column + 3) = ""
        End If
    
    End If
    
    End Sub

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How can I trick excel into thinking cell data has changed?

    Range(Cells(RowCnt, "2")).Select
    Selection.ClearConents
    should not compile or run-it oughta be
    Cells(RowCnt, 2).Select
    Selection.ClearContents
    or simply
    Cells(RowCnt, 2).ClearContents
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How can I trick excel into thinking cell data has changed?

    Thanks Josie,

    It was running before, but this seems simpler anyway. It runs ok, but now the problem is, if you look at the other set of code I posted, it only seems to run the segment that ends up setting the one column to red/yellow 1, 2. For whatever reason it never will set the cells to 3 when I use the button, but when I activate it by changing the date normally, it works fine, i see no reason why this would happen.


    Quote Originally Posted by JosephP View Post
    Range(Cells(RowCnt, "2")).Select
    Selection.ClearConents
    should not compile or run-it oughta be
    Cells(RowCnt, 2).Select
    Selection.ClearContents
    or simply
    Cells(RowCnt, 2).ClearContents

  5. #5
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How can I trick excel into thinking cell data has changed?

    Magically all I did was change startrow in the module macro from 2, to 3, and it all works perfectly now... no idea why this would do anything signifigant like that.

  6. #6
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How can I trick excel into thinking cell data has changed?

    wrong attachmenet

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel 2010 Identifying data changed in cells and Identifying the changed rows
    By SandyLake in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-13-2013, 01:12 AM
  2. [SOLVED] Data Validation Trick
    By excelaron in forum Excel General
    Replies: 1
    Last Post: 07-30-2012, 06:14 PM
  3. PLEASE Help excel pro's (Macro, excel related)
    By msu4life in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2012, 02:42 PM
  4. Excel formula trick ??
    By mbuckley56 in forum Excel General
    Replies: 2
    Last Post: 08-18-2010, 05:13 PM
  5. trick to append data from different sheets
    By all4excel in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-16-2007, 02:23 AM

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