MrSourApple
New Member
- Joined
- Oct 23, 2015
- Messages
- 17
I am trying to use vba to create conditional formatting rule for a range.
If cell J8 does not equal "N/A" I want the cell to be highlighted yellow. I then need to copy cell J8 and paste down to the last row of data in column J (rows will vary so I can't specify a row).
Right now I have the following code, but the issue I am having is that it highlights the cell regardless of the value. When I check the conditional formatting rules it shows the correct formula, but for format it says "No Format Set". So I think this code is just formatting all of the cells yellow and it isn't being considered a part of the "conditional formatting" rule.
If cell J8 does not equal "N/A" I want the cell to be highlighted yellow. I then need to copy cell J8 and paste down to the last row of data in column J (rows will vary so I can't specify a row).
Right now I have the following code, but the issue I am having is that it highlights the cell regardless of the value. When I check the conditional formatting rules it shows the correct formula, but for format it says "No Format Set". So I think this code is just formatting all of the cells yellow and it isn't being considered a part of the "conditional formatting" rule.
Code:
With Range("J8")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Operator:=xlNotEqual, _
Formula1:="=J8<>""N/A"""
Interior.Color = vbYellow
End With
Dim CopyDown As Long
CopyDown = ActiveSheet.UsedRange.Rows.Count
Range("J8").AutoFill Destination:=Range("J8:J" & CopyDown)