antman2988
Board Regular
- Joined
- Jun 28, 2018
- Messages
- 78
I have a cell that is highlighted yellow if a checkbox is checked.
I want to restrict printing if this cell is still highlighted, but my macro is not working.
My code to highlight (fill) the cell based on whether a checkbox is checked is as follows:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub CheckBox76_Click()
If ActiveSheet.Shapes("Check Box 76").ControlFormat.Value =1Then
Range("G54").Interior.Color = vbYellow
MsgBox ("Please enter the CFDA number in the highlighted field (G54).")
Else
Range("G54").Interior.Color = RGB(221,235,247)
EndIf
EndSub
</code>Code to check if cell is filled in and restrict printing if it is.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">PrivateSub Workbook_BeforePrint(Cancel AsBoolean)
Dim rRng As Range
Dim rCell As Range
Set rRng = ActiveWorkbook.Sheets("Assign_FI$Cal_Project_Code").UsedRange
If ActiveSheet.Name ="Assign_FI$Cal_Project_Code"Then
ForEach rCell In rRng.Cells
If rCell.Interior.Color = vbYellow Then
Cancel =True
MsgBox "Please fill in highlighted cells before printing."
EndIf
Next rCell
EndIf
EndSub</code>
I want to restrict printing if this cell is still highlighted, but my macro is not working.
My code to highlight (fill) the cell based on whether a checkbox is checked is as follows:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub CheckBox76_Click()
If ActiveSheet.Shapes("Check Box 76").ControlFormat.Value =1Then
Range("G54").Interior.Color = vbYellow
MsgBox ("Please enter the CFDA number in the highlighted field (G54).")
Else
Range("G54").Interior.Color = RGB(221,235,247)
EndIf
EndSub
</code>Code to check if cell is filled in and restrict printing if it is.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">PrivateSub Workbook_BeforePrint(Cancel AsBoolean)
Dim rRng As Range
Dim rCell As Range
Set rRng = ActiveWorkbook.Sheets("Assign_FI$Cal_Project_Code").UsedRange
If ActiveSheet.Name ="Assign_FI$Cal_Project_Code"Then
ForEach rCell In rRng.Cells
If rCell.Interior.Color = vbYellow Then
Cancel =True
MsgBox "Please fill in highlighted cells before printing."
EndIf
Next rCell
EndIf
EndSub</code>