if you want to change the color of a row on the basis of value entered in a cell.
Here is the code which you can use in workshseet change event-
For example - if some one type A in any cell of column "A" then entire row dhould be filled with red color
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Dim abc As Range
' taken target.column = 1 bcoz "a" is 1st column
If Target.Column = 1 Then
Set abc = Range("A" & Target.Row & ":A" & Target.Row + Target.Rows.Count)
For Each cell In abc
Select Case cell.Value
Case "A"
cell.EntireRow.Interior.Color = RGB(255, 0, 0)
Case "B"
cell.EntireRow.Interior.Color = RGB(0, 0, 255)
Case "C"
cell.EntireRow.Interior.Color = RGB(255, 255, 0)
Case Else
cell.EntireRow.Interior.Color = xlNone
End Select
Next cell
End If
End Sub
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
If you want to add a new menu on mouse right click "Workbook Navigation showing you the list of all open workbooks and worksheets in ea...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
Download Excel File
ReplyDeletehttp://www.filefactory.com/file/cc3f786/n/Conditional_Formatting.xlsm