![]() |
Changing the text color of a complete row ...
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. |
Changing the text color of a complete row ...
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. |
Changing the text color of a complete row ...
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. |
Changing the text color of a complete row ...
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. |
Changing the text color of a complete row ...
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. |
Changing the text color of a complete row ...
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. |
Changing the text color of a complete row ...
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. |
All times are GMT +1. The time now is 04:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com