This code checks if a string contains a certain text to set other values to something.
I structured my code to contain a lot of if elseif
statements which I have been told makes my code less efficient and slower.
I did begin a table to try to use VLookUp
.
Picture of my data:
Portion of my code.
If wsName = "TEST-3" Then
If rate_value < 50 Then
vol = 95
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
MsgBox "Less than 50."
ElseIf rate_value = 50 Then
vol = 98
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
sweep_value = 49.8
sweep_value_max = 50.2
ElseIf rate_value = 100 Then
vol = 110
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
sweep_value = 99.8
sweep_value_max = 100.2
Else: rate_value = 200
vol = 110
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
sweep_value = 199.4
sweep_value_max = 200.4
End If
ElseIf wsName = "TEST-8" Then
If rate_value < 50 Then
vol = 98
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
MsgBox "Less than 50."
ElseIf rate_value = 50 Then
vol = 98
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
sweep_value = 49.8
sweep_value_max = 50.2
ElseIf rate_value = 100 Then
vol = 125
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
sweep_value = 99.8
sweep_value_max = 100.2
Else: rate_value = 200
vol = 125
Call updateSD(sysnum, vol_rowindex, max, vol)
Call updateSD(sysnum, vol_rowindex_1, max, vol)
sweep_value = 199.4
sweep_value_max = 200.4
End If
End If
Call updateSD(sysnum, rate_rowindex, typ, rate_value)
Call updateSD(sysnum, rate_rowindex_1, typ, rate_value)
Call updateSD(sysnum, rate_rowindex_1, min, sweep_value)
Call updateSD(sysnum, rate_rowindex_1, max, sweep_value_max)
Sub updateSD(sysnum As String, rowindex As Double, columnindex As Long, Value As Double)
Worksheets(sysnum).Cells(rowindex, columnindex) = Value
Worksheets(sysnum).Cells(rowindex, columnindex).Interior.Color = vbYellow
End Sub