Here is the code that I have so far. The conditional formatting arguments aren't being passed right. For example, if the user enters NAME_ the length of that string should be 5 characters and inserted appropriately into Formula1 below.
Sub ApplyCF()
Dim var1 As Integer
Dim var2 As String
var2 = InputBox("Enter a String", "Input")
var1 = Len(var2)
With Columns("C")
.Select '2007 & earlier
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
'Formula1:=:=LEFT(C1,5)=""NAME_"""
Formula1:="=LEFT(C1,var1)=""var2"""
.FormatConditions(1).Interior.ColorIndex = 35
MsgBox "Value added to total."
End With
End Sub
Sub ApplyCF()
Dim var1 As Integer
Dim var2 As String
var2 = InputBox("Enter a String", "Input")
var1 = Len(var2)
With Columns("C")
.Select '2007 & earlier
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
'Formula1:=:=LEFT(C1,5)=""NAME_"""
Formula1:="=LEFT(C1,var1)=""var2"""
.FormatConditions(1).Interior.ColorIndex = 35
MsgBox "Value added to total."
End With
End Sub