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
Showing posts with label Change the color of row on the basis of value entered in cell using VBA. Show all posts
Showing posts with label Change the color of row on the basis of value entered in cell using VBA. Show all posts
Subscribe to:
Posts (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 run SQL queries within Excel environment without connecting to any database, you can do it with creating the ADODB conn...
-
Macro to send b'day message automatically Snapshot of email: Snapshot of data: Method 1 Add image using web lin...