Results 1 to 2 of 2

Macro function only runs once

Threaded View

  1. #1
    Registered User
    Join Date
    07-28-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    1

    Macro function only runs once

    Hi there,

    So i've got a function in excel that basically adds up how many yellow cells there are the row.



    Function CountColorIf(rArea As Range) As Long
        
            Dim rAreaCell As Range
            Dim lCounter As Long
       
        
            For Each rAreaCell In rArea
        
                If rAreaCell.Interior.ColorIndex = 6 Then
        
                    lCounter = lCounter + 1
        
                End If
        
            Next rAreaCell
        
            CountColorIf = lCounter
        End function
    The code works, however not immediately... So, for instance say I make two of the cells yellow, I then have to click backinto the cell in which this function is placed and press enter for the correct number to appear.

    Can anyone show me how to make it so it runs any time the worksheet is changed?

    I did findsomething about Worksheet.event (sorry something like that) but from my understanding that only works with a sub and not a function.

    Any help would be really appretiated!

    Cheers

    Sam
    Last edited by Peroni89; 07-28-2015 at 02:19 PM. Reason: Remove double code tag

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA runs slow locally, runs fine when connected remotely
    By jbzy324 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2015, 10:05 PM
  2. [SOLVED] Function runs within a workbook but not as AddIn
    By JimDandy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-06-2014, 11:11 PM
  3. Replies: 0
    Last Post: 08-16-2012, 01:32 PM
  4. Disable Function while Macro Runs
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2011, 05:29 PM
  5. Replies: 1
    Last Post: 07-15-2011, 01:24 AM
  6. Button the runs a function
    By Lambda09a in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2008, 04:43 AM
  7. Function runs more than once
    By Huyeote in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2006, 03:10 AM

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