+ Reply to Thread
Results 1 to 10 of 10

Flashing Cells

  1. #1
    Registered User
    Join Date
    01-21-2004
    Posts
    21

    Flashing Cells

    Hi everybody,

    I have a code that makes a specific cell blinking .. it works very well, but with one cell only .. I tried to develop it to be active with more than one cell, but I could not.

    This is the code and I wish I could find the answer here:

    Public Sub Blink()
    With Sheets(1).Range("A1").Interior
    If .ColorIndex = 2 Then
    .ColorIndex = 3
    Else
    .ColorIndex = 2
    End If
    End With
    appTime = Now() + TimeValue("00:00:01")
    Application.OnTime appTime, "Blink"
    End Sub


    Thank you,
    Attached Files Attached Files
    Last edited by Jim333; 09-05-2005 at 01:48 AM.

  2. #2
    Robin Hammond
    Guest

    Re: Flashing Cells

    Jim,

    this is untested but it would go something like this

    > Public Sub Blink()

    Dim rngCell as range
    Dim rngRegion as range
    set rngRegion =Sheets(1).Range("A1:d10")
    for each rngCell in rngRegion
    .Interior.ColorIndex = iif(.Interior.ColorIndex = 2,3,2)
    Next rngCell
    appTime = Now() + TimeValue("00:00:01")
    Application.OnTime appTime, "Blink"
    End Sub

    Robin Hammond
    www.enhanceddatasystems.com

    "Jim333" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi everybody,
    >
    > I have a code that makes a specific cell blinking .. it works very
    > well, but with one cell only .. I tried to develop it to be active with
    > more than one cell, but I could not.
    >
    > This is the code and I wish I could find the answer here:
    >
    > Public Sub Blink()
    > With Sheets(1).Range("A1").Interior
    > If .ColorIndex = 2 Then
    > ColorIndex = 3
    > Else
    > ColorIndex = 2
    > End If
    > End With
    > appTime = Now() + TimeValue("00:00:01")
    > Application.OnTime appTime, "Blink"
    > End Sub
    >
    > Thank you,
    >
    >
    > --
    > Jim333
    > ------------------------------------------------------------------------
    > Jim333's Profile:
    > http://www.excelforum.com/member.php...fo&userid=5186
    > View this thread: http://www.excelforum.com/showthread...hreadid=401858
    >




  3. #3
    Registered User
    Join Date
    01-21-2004
    Posts
    21
    Thank you for ur reply,

    the code didn't work with me,,

    Can u please test it and attach a file contains the tested code,

    thanks,

  4. #4
    Norman Jones
    Guest

    Re: Flashing Cells

    Hi Jim,

    Inserting a clearly intended With...End With clause, Robin's code ran
    without problem for me:

    Public Sub Blink()
    Dim rngCell As Range
    Dim rngRegion As Range
    Dim appTime As Double
    Set rngRegion = Sheets(1).Range("A1:d10")
    For Each rngCell In rngRegion
    With rngCell
    .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    End With
    Next rngCell
    appTime = Now() + TimeValue("00:00:01")
    Application.OnTime appTime, "Blink"
    End Sub

    ---
    Regards,
    Norman


    "Jim333" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Thank you for ur reply,
    >
    > the code didn't work with me,,
    >
    > Can u please test it and attach a file contains the tested code,
    >
    > thanks,
    >
    >
    > --
    > Jim333
    > ------------------------------------------------------------------------
    > Jim333's Profile:
    > http://www.excelforum.com/member.php...fo&userid=5186
    > View this thread: http://www.excelforum.com/showthread...hreadid=401858
    >




  5. #5
    Robin Hammond
    Guest

    Re: Flashing Cells

    Thankyou Norman.

    My mistake Jim.

    Robin Hammond
    www.enhanceddatasystems.com

    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Jim,
    >
    > Inserting a clearly intended With...End With clause, Robin's code ran
    > without problem for me:
    >
    > Public Sub Blink()
    > Dim rngCell As Range
    > Dim rngRegion As Range
    > Dim appTime As Double
    > Set rngRegion = Sheets(1).Range("A1:d10")
    > For Each rngCell In rngRegion
    > With rngCell
    > .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    > End With
    > Next rngCell
    > appTime = Now() + TimeValue("00:00:01")
    > Application.OnTime appTime, "Blink"
    > End Sub
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Jim333" <[email protected]> wrote in
    > message news:[email protected]...
    >>
    >> Thank you for ur reply,
    >>
    >> the code didn't work with me,,
    >>
    >> Can u please test it and attach a file contains the tested code,
    >>
    >> thanks,
    >>
    >>
    >> --
    >> Jim333
    >> ------------------------------------------------------------------------
    >> Jim333's Profile:
    >> http://www.excelforum.com/member.php...fo&userid=5186
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=401858
    >>

    >
    >




  6. #6
    Forum Contributor
    Join Date
    02-26-2005
    Posts
    175
    Hi Norman,

    And the code to turn this off would be ??

    Dave
    Don't say the trash can.

    Quote Originally Posted by Norman Jones
    Hi Jim,

    Inserting a clearly intended With...End With clause, Robin's code ran
    without problem for me:

    Public Sub Blink()
    Dim rngCell As Range
    Dim rngRegion As Range
    Dim appTime As Double
    Set rngRegion = Sheets(1).Range("A1:d10")
    For Each rngCell In rngRegion
    With rngCell
    .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    End With
    Next rngCell
    appTime = Now() + TimeValue("00:00:01")
    Application.OnTime appTime, "Blink"
    End Sub

    ---
    Regards,
    Norman


    "Jim333" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Thank you for ur reply,
    >
    > the code didn't work with me,,
    >
    > Can u please test it and attach a file contains the tested code,
    >
    > thanks,
    >
    >
    > --
    > Jim333
    > ------------------------------------------------------------------------
    > Jim333's Profile:
    > http://www.excelforum.com/member.php...fo&userid=5186
    > View this thread: http://www.excelforum.com/showthread...hreadid=401858
    >

  7. #7
    Norman Jones
    Guest

    Re: Flashing Cells

    Hi Dave,

    Perhaps, by using a module level boolean (blStop) in conjunction with a
    macro (StartIt) to inititiate the blink routine and a macro (StopIt) to
    terminate the blink routine

    '======================>>
    Option Explicit
    Public blStop As Boolean

    '------------------------------
    Public Sub Blink()
    Dim rngCell As Range
    Dim rngRegion As Range
    Dim appTime As Double

    If blStop Then Exit Sub
    Set rngRegion = Sheets(1).Range("A1:d10")
    For Each rngCell In rngRegion
    With rngCell
    .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    End With
    Next rngCell
    appTime = Now() + TimeValue("00:00:01")
    Application.OnTime appTime, "Blink"
    End Sub

    '------------------------------

    Public Sub StartIt()
    blStop = False
    Blink
    End Sub

    '------------------------------

    Public Sub StopIt()
    blStop = True
    End Sub:

    '<<======================

    BTW, Dave, I sincerely hope that you have not been converted to flash /
    blink phenomena - I thought *you* had more sense!


    ---
    Regards,
    Norman



    "Piranha" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi Norman,
    >
    > And the code to turn this off would be ??
    >
    > Dave
    > Don't say the trash can.
    >
    > Norman Jones Wrote:
    >> Hi Jim,
    >>
    >> Inserting a clearly intended With...End With clause, Robin's code ran
    >> without problem for me:
    >>
    >> Public Sub Blink()
    >> Dim rngCell As Range
    >> Dim rngRegion As Range
    >> Dim appTime As Double
    >> Set rngRegion = Sheets(1).Range("A1:d10")
    >> For Each rngCell In rngRegion
    >> With rngCell
    >> .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    >> End With
    >> Next rngCell
    >> appTime = Now() + TimeValue("00:00:01")
    >> Application.OnTime appTime, "Blink"
    >> End Sub
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >> "Jim333" <[email protected]> wrote
    >> in
    >> message news:[email protected]...
    >> >
    >> > Thank you for ur reply,
    >> >
    >> > the code didn't work with me,,
    >> >
    >> > Can u please test it and attach a file contains the tested code,
    >> >
    >> > thanks,
    >> >
    >> >
    >> > --
    >> > Jim333
    >> >

    >> ------------------------------------------------------------------------
    >> > Jim333's Profile:
    >> > http://www.excelforum.com/member.php...fo&userid=5186
    >> > View this thread:

    >> http://www.excelforum.com/showthread...hreadid=401858
    >> >

    >
    >
    > --
    > Piranha
    >
    >
    > ------------------------------------------------------------------------
    > Piranha's Profile:
    > http://www.excelforum.com/member.php...o&userid=20435
    > View this thread: http://www.excelforum.com/showthread...hreadid=401858
    >




  8. #8
    Robin Hammond
    Guest

    Re: Flashing Cells

    Was just working on a similar answer. Only difference to Norman is that this
    allows you to store the range and it sets the cell colours back to white.

    Private appTime As Double
    Private rngSaved As Range
    Private bStop As Boolean

    Sub Test()
    InitBlinking ActiveSheet.Range("a1:d5")
    End Sub

    Sub InitBlinking(rngBlink As Range)
    Set rngSaved = rngBlink
    bStop = False
    Blink
    End Sub

    Sub StopBlinking()
    bStop = True
    'if you were running longer delays you would also want code like this
    'application.OnTime apptime,"Blink",,false
    'For Each rngCell In rngSaved
    'rngCell.Interior.ColorIndex = 2
    'Next rngCell
    End Sub

    Public Sub Blink()
    Dim rngCell As Range
    For Each rngCell In rngSaved
    With rngCell
    If bStop Then
    .Interior.ColorIndex = 2
    Else
    .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    End If
    End With
    Next rngCell
    If Not bStop Then
    appTime = Now() + TimeValue("00:00:01")
    Application.OnTime appTime, "Blink"
    End If
    End Sub

    Robin Hammond
    www.enhanceddatasystems.com

    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Dave,
    >
    > Perhaps, by using a module level boolean (blStop) in conjunction with a
    > macro (StartIt) to inititiate the blink routine and a macro (StopIt) to
    > terminate the blink routine
    >
    > '======================>>
    > Option Explicit
    > Public blStop As Boolean
    >
    > '------------------------------
    > Public Sub Blink()
    > Dim rngCell As Range
    > Dim rngRegion As Range
    > Dim appTime As Double
    >
    > If blStop Then Exit Sub
    > Set rngRegion = Sheets(1).Range("A1:d10")
    > For Each rngCell In rngRegion
    > With rngCell
    > .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    > End With
    > Next rngCell
    > appTime = Now() + TimeValue("00:00:01")
    > Application.OnTime appTime, "Blink"
    > End Sub
    >
    > '------------------------------
    >
    > Public Sub StartIt()
    > blStop = False
    > Blink
    > End Sub
    >
    > '------------------------------
    >
    > Public Sub StopIt()
    > blStop = True
    > End Sub:
    >
    > '<<======================
    >
    > BTW, Dave, I sincerely hope that you have not been converted to flash /
    > blink phenomena - I thought *you* had more sense!
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Piranha" <[email protected]> wrote in
    > message news:[email protected]...
    >>
    >> Hi Norman,
    >>
    >> And the code to turn this off would be ??
    >>
    >> Dave
    >> Don't say the trash can.
    >>
    >> Norman Jones Wrote:
    >>> Hi Jim,
    >>>
    >>> Inserting a clearly intended With...End With clause, Robin's code ran
    >>> without problem for me:
    >>>
    >>> Public Sub Blink()
    >>> Dim rngCell As Range
    >>> Dim rngRegion As Range
    >>> Dim appTime As Double
    >>> Set rngRegion = Sheets(1).Range("A1:d10")
    >>> For Each rngCell In rngRegion
    >>> With rngCell
    >>> .Interior.ColorIndex = IIf(.Interior.ColorIndex = 2, 3, 2)
    >>> End With
    >>> Next rngCell
    >>> appTime = Now() + TimeValue("00:00:01")
    >>> Application.OnTime appTime, "Blink"
    >>> End Sub
    >>>
    >>> ---
    >>> Regards,
    >>> Norman
    >>>
    >>>
    >>> "Jim333" <[email protected]> wrote
    >>> in
    >>> message news:[email protected]...
    >>> >
    >>> > Thank you for ur reply,
    >>> >
    >>> > the code didn't work with me,,
    >>> >
    >>> > Can u please test it and attach a file contains the tested code,
    >>> >
    >>> > thanks,
    >>> >
    >>> >
    >>> > --
    >>> > Jim333
    >>> >
    >>> ------------------------------------------------------------------------
    >>> > Jim333's Profile:
    >>> > http://www.excelforum.com/member.php...fo&userid=5186
    >>> > View this thread:
    >>> http://www.excelforum.com/showthread...hreadid=401858
    >>> >

    >>
    >>
    >> --
    >> Piranha
    >>
    >>
    >> ------------------------------------------------------------------------
    >> Piranha's Profile:
    >> http://www.excelforum.com/member.php...o&userid=20435
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=401858
    >>

    >
    >




  9. #9
    Forum Contributor
    Join Date
    02-26-2005
    Posts
    175
    Hi Norman,
    he he he, Well im kinda old for the flashing but i am after the knowledge. I want to fill the unused space in my brain. (don't want any blank cells)
    Your code works great, as expected.

    Hi Robin,
    Your code works great as well.

    thx to both of you
    Dave
    [QUOTE=Norman Jones]Hi Dave,

    Perhaps, by using a module level boolean (blStop) in conjunction with a
    macro (StartIt) to inititiate the blink routine and a macro (StopIt) to
    terminate the blink routine

    BTW, Dave, I sincerely hope that you have not been converted to flash /
    blink phenomena - I thought *you* had more sense!
    Regards,QUOTE]
    [QUOTE=Robin Hammond] Was just working on a similar answer. Only difference to Norman is that this
    allows you to store the range and it sets the cell colours back to white.QUOTE]

  10. #10
    Registered User
    Join Date
    01-21-2004
    Posts
    21
    Hi everybody,

    Thanks you for everyone participated in this topic, especially Robin and Norman >> Thank you sooooooooo much for the great help you delivered.
    Last edited by Jim333; 09-10-2005 at 06:32 AM.

+ 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