Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting the color for each cell in a selection
OK, so I pressed the wrong key before my message was complete, but I'll
reiterate what I was trying to do. I need to check the color of each cell within a one-row selection so that if the scheduler picks the wrong selection, then they do not receive an Outlook appointment. I need to use a command button to provide flexibility. Here's part of the sub: Dim rng As Range For Each rng in Selection If rng.Interior.ColorIndex < 4 Then MsgBox "You did not select the correct cells for scheduling", vbCritical, "Improper Selection" End If Exit Sub Next What am I missing here? Thanks, -- Brian J. Matuschak |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting the color for each cell in a selection
I think you just put the exit sub in the wrong place (outside the if
statement) Die_Another_Day For Each rng in Selection If rng.Interior.ColorIndex < 4 Then MsgBox "You did not select the correct cells for scheduling", vbCritical, "Improper Selection" Exit Sub End If Next Brian J. Matuschak wrote: OK, so I pressed the wrong key before my message was complete, but I'll reiterate what I was trying to do. I need to check the color of each cell within a one-row selection so that if the scheduler picks the wrong selection, then they do not receive an Outlook appointment. I need to use a command button to provide flexibility. Here's part of the sub: Dim rng As Range For Each rng in Selection If rng.Interior.ColorIndex < 4 Then MsgBox "You did not select the correct cells for scheduling", vbCritical, "Improper Selection" End If Exit Sub Next What am I missing here? Thanks, -- Brian J. Matuschak |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting the color for each cell in a selection
An easy fix:
Your Exit sub is inside the For Loop. You are only going thru the loop once, not for every cell in Selection. Move the Exit inside the IF -- Gary's Student "Brian J. Matuschak" wrote: OK, so I pressed the wrong key before my message was complete, but I'll reiterate what I was trying to do. I need to check the color of each cell within a one-row selection so that if the scheduler picks the wrong selection, then they do not receive an Outlook appointment. I need to use a command button to provide flexibility. Here's part of the sub: Dim rng As Range For Each rng in Selection If rng.Interior.ColorIndex < 4 Then MsgBox "You did not select the correct cells for scheduling", vbCritical, "Improper Selection" End If Exit Sub Next What am I missing here? Thanks, -- Brian J. Matuschak |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting the color for each cell in a selection
Exit sub should be within the IF statement right after the msgbox
-- Regards, Tom Ogilvy "Brian J. Matuschak" wrote: OK, so I pressed the wrong key before my message was complete, but I'll reiterate what I was trying to do. I need to check the color of each cell within a one-row selection so that if the scheduler picks the wrong selection, then they do not receive an Outlook appointment. I need to use a command button to provide flexibility. Here's part of the sub: Dim rng As Range For Each rng in Selection If rng.Interior.ColorIndex < 4 Then MsgBox "You did not select the correct cells for scheduling", vbCritical, "Improper Selection" End If Exit Sub Next What am I missing here? Thanks, -- Brian J. Matuschak |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing the color of Cell Selection? | Excel Discussion (Misc queries) | |||
Cell Range Selection Color | Excel Discussion (Misc queries) | |||
How do I change the color for cell selection in excel? | New Users to Excel | |||
Change Cell background color by selection | Excel Worksheet Functions | |||
Getting color of each cell in selection | Excel Programming |