Hey, I'm new to coding in VBA and have a question regarding conditional formatting and macros. Currently the macro works with the code below to compare the values in 10 columns to standards in 3 columns. Each row must be compared to the corresponding standards in that row.
Sub ConditionalFormattingDataTables()
'selects range for formatting'
Dim MyRange As Range
Set MyRange = Application.InputBox(prompt:="Input the range of cells for formatting", Type:=8)
'Clears previous formating if any in selected area'
MyRange.FormatConditions.Delete
'Determines if any given data point is between standard 1 and standard 2 and formats properly'
MyRange.Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(E15>=$D15,E15<$C15,E15<$B15)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = True
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
The issue is that based on the code the columns containing the standards each row must be compared to have to be manually entered into the code for each spreadsheet ($D15, $C15, $B15). Additionally the top left corner of the area to be formatted also has to be manually entered (E15). The goal is to use an input box for the user to be able to select each of these parameters so that the macro is flexible and works on various size spreadsheets. I was wondering if this is possible, or if I should write the code a different way.
Thanks
Bookmarks