Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When a check box is ticked, I would like to automatically change any whote
cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Public Sub PriorityWarning()
Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry Joel nothing happens apart from showing the msgbox, but it has
eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
All that means is the present color of the cell is not the two choise you
have in the code. Color is a problem becuase RGB sets a number but color returns a string. Try colorindex Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.ColorIndex = xlNone Then .Interior.ColorIndex = 3 End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.ColorIndex = 3 Then .Interior.ColorIndex = xlNone End If End With End Sub "MarkyB" wrote: Sorry Joel nothing happens apart from showing the msgbox, but it has eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Joel, thanks for your help but still nothing happens. Still I have learnt
more. It was going to be a humurous aspect to a client brief that when they request an urgent priority we would try to flash the colours and show a msgbox. msgbox works fine! "Joel" wrote: All that means is the present color of the cell is not the two choise you have in the code. Color is a problem becuase RGB sets a number but color returns a string. Try colorindex Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.ColorIndex = xlNone Then .Interior.ColorIndex = 3 End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.ColorIndex = 3 Then .Interior.ColorIndex = xlNone End If End With End Sub "MarkyB" wrote: Sorry Joel nothing happens apart from showing the msgbox, but it has eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It means that the current color of the cell is something other than None or
Red. none will equal -4142 or red will equal 3 try executing this line and see which color is returned MsgBox ("Current color is " & ActiveCell.Interior.ColorIndex) "MarkyB" wrote: Hi Joel, thanks for your help but still nothing happens. Still I have learnt more. It was going to be a humurous aspect to a client brief that when they request an urgent priority we would try to flash the colours and show a msgbox. msgbox works fine! "Joel" wrote: All that means is the present color of the cell is not the two choise you have in the code. Color is a problem becuase RGB sets a number but color returns a string. Try colorindex Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.ColorIndex = xlNone Then .Interior.ColorIndex = 3 End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.ColorIndex = 3 Then .Interior.ColorIndex = xlNone End If End With End Sub "MarkyB" wrote: Sorry Joel nothing happens apart from showing the msgbox, but it has eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nope, still no change. Index is indeed -4142. Only thing to happen is the
msgbox. "Joel" wrote: It means that the current color of the cell is something other than None or Red. none will equal -4142 or red will equal 3 try executing this line and see which color is returned MsgBox ("Current color is " & ActiveCell.Interior.ColorIndex) "MarkyB" wrote: Hi Joel, thanks for your help but still nothing happens. Still I have learnt more. It was going to be a humurous aspect to a client brief that when they request an urgent priority we would try to flash the colours and show a msgbox. msgbox works fine! "Joel" wrote: All that means is the present color of the cell is not the two choise you have in the code. Color is a problem becuase RGB sets a number but color returns a string. Try colorindex Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.ColorIndex = xlNone Then .Interior.ColorIndex = 3 End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.ColorIndex = 3 Then .Interior.ColorIndex = xlNone End If End With End Sub "MarkyB" wrote: Sorry Joel nothing happens apart from showing the msgbox, but it has eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Isn't the cell red when the message box appears? Then turns back to blank
after message box closes "MarkyB" wrote: Nope, still no change. Index is indeed -4142. Only thing to happen is the msgbox. "Joel" wrote: It means that the current color of the cell is something other than None or Red. none will equal -4142 or red will equal 3 try executing this line and see which color is returned MsgBox ("Current color is " & ActiveCell.Interior.ColorIndex) "MarkyB" wrote: Hi Joel, thanks for your help but still nothing happens. Still I have learnt more. It was going to be a humurous aspect to a client brief that when they request an urgent priority we would try to flash the colours and show a msgbox. msgbox works fine! "Joel" wrote: All that means is the present color of the cell is not the two choise you have in the code. Color is a problem becuase RGB sets a number but color returns a string. Try colorindex Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.ColorIndex = xlNone Then .Interior.ColorIndex = 3 End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.ColorIndex = 3 Then .Interior.ColorIndex = xlNone End If End With End Sub "MarkyB" wrote: Sorry Joel nothing happens apart from showing the msgbox, but it has eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Brilliant! Must have had another cell active that I couldn't see on screen.
Thanks a million Joel "Joel" wrote: Isn't the cell red when the message box appears? Then turns back to blank after message box closes "MarkyB" wrote: Nope, still no change. Index is indeed -4142. Only thing to happen is the msgbox. "Joel" wrote: It means that the current color of the cell is something other than None or Red. none will equal -4142 or red will equal 3 try executing this line and see which color is returned MsgBox ("Current color is " & ActiveCell.Interior.ColorIndex) "MarkyB" wrote: Hi Joel, thanks for your help but still nothing happens. Still I have learnt more. It was going to be a humurous aspect to a client brief that when they request an urgent priority we would try to flash the colours and show a msgbox. msgbox works fine! "Joel" wrote: All that means is the present color of the cell is not the two choise you have in the code. Color is a problem becuase RGB sets a number but color returns a string. Try colorindex Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.ColorIndex = xlNone Then .Interior.ColorIndex = 3 End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.ColorIndex = 3 Then .Interior.ColorIndex = xlNone End If End With End Sub "MarkyB" wrote: Sorry Joel nothing happens apart from showing the msgbox, but it has eliminated the run-time error.. "Joel" wrote: Public Sub PriorityWarning() Sheets(1).Activate With ActiveCell If .Interior.Color = RGB(255, 255, 255) Then .Interior.Color = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .Interior.Color = RGB(255, 51, 0) Then .Interior.Color = RGB(255, 255, 255) End If End With End Sub "MarkyB" wrote: When a check box is ticked, I would like to automatically change any whote cells to red, throw up the MsgBox and then change the red back again to white. When I call the macro I get a run-time error '438'. My code that I am trying to use is: Public Sub PriorityWarning() With Sheets(1) Cells.Select If .BackColor = RGB(255, 255, 255) Then .BackColor = RGB(255, 51, 0) End If MsgBox "Priority EPCON1!", vbOKOnly, "EPCON LEVEL" If .BackColor = RGB(255, 51, 0) Then .BackColor = RGB(255, 255, 255) End If End With End Sub Thanks, Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I set all my worksheet background colours to white? | New Users to Excel | |||
Remove white spaces in Back | Excel Discussion (Misc queries) | |||
EXCEL workbook is off-white, goes white in edit mode | Excel Discussion (Misc queries) | |||
Is it possible to make a cell flash between 2 colours? | Excel Worksheet Functions | |||
Excel 2003 font colours and cell colours | Excel Discussion (Misc queries) |