Hi all,
I am trying to make a dynamic formula by using the >=< signs and referencing them from the spreadsheet i.e. I do not want to use them directly in the VBA code. I started writing this (code below just to show my attempt) but then I realised I did not know how to set up the forumla by referencing the >=< signs and the numbers in the spreadsheet (Spreadsheet attached).
Option Explicit
Sub RuleTesting()
Dim QRule As String
Dim RTRule As String
Dim CurrentResult As Integer
Dim Red As String
Dim Amber As String
Dim Green As String
' Variables
QRule = Sheets("Results_Q").Range("E2").Value
RTRule = Sheets("RuleTable_RT").Range("A2").Value
Red = Sheets("RuleTable_RT").Range("B2").Value & Sheets("RuleTable_RT").Range("C2").Value
Green = Sheets("RuleTable_RT").Range("F2").Value & Sheets("RuleTable_RT").Range("G2").Value
If QRule = RTRule Then
CurrentResult = Sheets("Results_Q").Range("D2")
Else
End If
If CurrentResult = Red Then
Sheets("Results_Q").Range("F2").Value = Red
ElseIf CurrentResult = Green Then
Sheets("Results_Q").Range("F2").Value = Green
Else
Sheets("Results_Q").Range("F2").Value = Amber
End If
End Sub
P.s. I have recently attended introduction and intermediate courses so I am relatively new to VBA. Any help would be much appreciated.
Regards,
Forrestgump
Bookmarks