Forum Discussion
blink a cell
- Mar 23, 2018
Hello.
If i recall correctly. I think i have answered similar question like this before.
I think you may have difficulty on how to replicate the solution in your own file.I have recorded a video on how you can do it by yourself.
This is the first part of the code that goes to a module
Option Explicit Public rRange As Range Dim dNextTime As Double Sub StartBlink() On Error GoTo ErrorHandle With rRange.Interior If .ColorIndex = 3 Then .ColorIndex = xlNone Else .ColorIndex = 3 End If End With dNextTime = Now + TimeSerial(0, 0, 1) Application.OnTime dNextTime, "StartBlink", , True Exit Sub ErrorHandle: MsgBox Err.Description & " Procedure StartBlink." Set rRange = Nothing End Sub Sub StopBlink() On Error GoTo ErrorHandle rRange.Interior.ColorIndex = xlNone Application.OnTime dNextTime, "StartBlink", , False BeforeExit: Set rRange = Nothing Exit Sub ErrorHandle: MsgBox Err.Description & " Procedure StopBlink." Resume BeforeExit End Suband this is the second part which goes to the Sheet Form object
Option Explicit Dim bCellCheck As Boolean Dim bBlink As Boolean Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim rColumn As Range Dim sAdress As String On Error GoTo ErrorHandle If Not IsEmpty(Range("B27")) Then Set rColumn = Range("B27") End If bCellCheck = False If Range("G27").Value = "" Then bCellCheck = True If Len(sAdress) > 0 Then sAdress = sAdress & "," & rColumn.Address Else sAdress = sAdress & rColumn.Address End If End If If bCellCheck = True And bBlink = False Then Set rRange = Range(sAdress) bBlink = True StartBlink ElseIf bCellCheck = True And bBlink = True Then Set rRange = rColumn StopBlink Set rRange = Range(sAdress) StartBlink ElseIf bCellCheck = False And bBlink = True Then Set rRange = rColumn StopBlink bBlink = False End If Exit Sub ErrorHandle: MsgBox Err.Description & " Procedure Worksheet_Change." Set rRange = Nothing Set rColumn = Nothing bCellCheck = False End Sub
THANK YOU FOR YOUR VALUABLE TIME
- Lorenzo KimMar 28, 2018Bronze Contributor
Mr Jamil Mohammad
I changed sub startblink() to function startblink() as boolean and this does not show up in the macro box, will this have any effect on the program?
I do not want the blinking to appear on macro box - this may be manually manipulated and could hamper the program
if not so much of asking - pls help on the COPY SHEET deactivation, too
Thank you very very much
- JamilMar 31, 2018Bronze Contributor
Please do not change anything as function and boolean. I have sent you an updated file just now. among other changes you have asked, I took care of the two sub not to show in the macro box. for your learning, if you do not want macros to be shown in macro box and you still want them to be available as public declaration then all you need to do is to add the below line at the beginning of the module
Option Private Module
for now, i have already placed this in your workbook. so you do not have to make changes
- Lorenzo KimMar 28, 2018Bronze Contributor
Mr Jamil Mohammad
ALSO: the startblink and stopblink should not appear in macro box
lest they be manipulated manually
should they be categorized as "private"? I really have no idea...
Thank you
- Lorenzo KimMar 27, 2018Bronze Contributor
Mr Jamil Mohammad
celebrated too soon!
the file you emailed runs just perfectly!!
but when I worksheet protect it, this happens
Thank you
- Lorenzo KimMar 27, 2018Bronze Contributor
Mr Jamil Mohammad
Thank you for being so patient with my queries
finally IT WAS DONE!!
maybe if it is not too much, the worksheet "Form" is the template
and I don't want it to be copied or duplicated within the workbook - what a mess it would be -- how could I deactivate the copy sheet function (Ctrl key +mouse dragging of sheet tag to the right) or the right click function, just for the worksheet "Form". protect workbook won't do it - as it freezes all worksheets!
Thank you again for your kind assistance
MORE POWER TO YOU