I’m trying to figure out a way to execute this code to run based on the headers in Row1 instead of defining “A1” as I am below. This works perfect, but if a column accidently gets moved I have to change it in vba manually.
So let’s say A1 = Toyota … how do I search all cells in the first row to match Toyota and then execute the condition?
Sub change()
Dim car As Range
For each car in Range("A1",Range("A" & Rows.Count).End((xlUp))
If car = “N/A” Then
car.Interior.Color = 65535
end if
Next Car
End sub
I have multiple conditions like this for multiple columns. So I'd just like to match up the column header to the if/then condition.
Thanks!
Aucun commentaire:
Enregistrer un commentaire