Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Looking for a solution please ... Before a workbook is saved, I would
like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean) Dim i As Long With Worksheets("Sheet1") For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row If .Cells(i, "A").Value < "" Then .Rows(i).Interior.ColorIndex = 3 End If Next i End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob Phillips "Rob Keel" wrote in message oups.com... Looking for a solution please ... Before a workbook is saved, I would like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excellent. Thank you very much for that Bob.
One more question though if you don't mind ... How would I amend this code to not include column headers i.e. the labels in row 1 of the sheet? Thanks. Rob. Bob Phillips wrote: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim i As Long With Worksheets("Sheet1") For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row If .Cells(i, "A").Value < "" Then .Rows(i).Interior.ColorIndex = 3 End If Next i End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob Phillips "Rob Keel" wrote in message oups.com... Looking for a solution please ... Before a workbook is saved, I would like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Start the loop at 2 instead of 1.
-- HTH Bob Phillips "Rob Keel" wrote in message ups.com... Excellent. Thank you very much for that Bob. One more question though if you don't mind ... How would I amend this code to not include column headers i.e. the labels in row 1 of the sheet? Thanks. Rob. Bob Phillips wrote: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim i As Long With Worksheets("Sheet1") For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row If .Cells(i, "A").Value < "" Then .Rows(i).Interior.ColorIndex = 3 End If Next i End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob Phillips "Rob Keel" wrote in message oups.com... Looking for a solution please ... Before a workbook is saved, I would like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Cheers Bob.
Sorry, I only recently started coding so a bit of a beginner at present. Once again, many thanks. Rob. Bob Phillips wrote: Start the loop at 2 instead of 1. -- HTH Bob Phillips "Rob Keel" wrote in message ups.com... Excellent. Thank you very much for that Bob. One more question though if you don't mind ... How would I amend this code to not include column headers i.e. the labels in row 1 of the sheet? Thanks. Rob. Bob Phillips wrote: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim i As Long With Worksheets("Sheet1") For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row If .Cells(i, "A").Value < "" Then .Rows(i).Interior.ColorIndex = 3 End If Next i End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob Phillips "Rob Keel" wrote in message oups.com... Looking for a solution please ... Before a workbook is saved, I would like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No problem, it is only obvious when you know it <vbg
regards Bob "Rob Keel" wrote in message oups.com... Cheers Bob. Sorry, I only recently started coding so a bit of a beginner at present. Once again, many thanks. Rob. Bob Phillips wrote: Start the loop at 2 instead of 1. -- HTH Bob Phillips "Rob Keel" wrote in message ups.com... Excellent. Thank you very much for that Bob. One more question though if you don't mind ... How would I amend this code to not include column headers i.e. the labels in row 1 of the sheet? Thanks. Rob. Bob Phillips wrote: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim i As Long With Worksheets("Sheet1") For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row If .Cells(i, "A").Value < "" Then .Rows(i).Interior.ColorIndex = 3 End If Next i End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob Phillips "Rob Keel" wrote in message oups.com... Looking for a solution please ... Before a workbook is saved, I would like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why not use conditional formatting?
Select row 1 and do Format = Conditional Formatting In the first dropdown in the dialog, change Cell Value is to Formula is enter a formula like =len(Trim($A$1))=0 click the format button and select your color -- Regards, Tom Ogilvy "Rob Keel" wrote in message oups.com... Looking for a solution please ... Before a workbook is saved, I would like excel to check the contents of cells in column A and if the cell is not empty then I would like excel to change the text color for the complete row to a different color (automatic to red for example). Can anyone offer a solution to this please? Many thanks for you help. Rob. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Changing text color based upon If | Excel Discussion (Misc queries) | |||
dynamically changing text color | Excel Worksheet Functions | |||
Changing several cells text color | Excel Discussion (Misc queries) | |||
Changing text color within a formula??? | Excel Discussion (Misc queries) | |||
Changing text color | Excel Programming |