Hi,
I haven't touched VBA for a long time and hopefully someone can provide the simplest solution.
I have a dropdown list of worksheet names and whicever option is chosen, I wish to then have formulas applied to that workseet.
Can someone please advise on how to approach this. Thank you
I haven't touched VBA for a long time and hopefully someone can provide the simplest solution.
I have a dropdown list of worksheet names and whicever option is chosen, I wish to then have formulas applied to that workseet.
Can someone please advise on how to approach this. Thank you
VBA Code:
Sub Commission_Percent()
Dim Lastrow As Long
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Dim strFormulas(1 To 4) As Variant
With Sheets("JBP") 'I want to dynnamically change this to what is entered in the Sheets("Commission").Range("C4").Select as there is a dropdown menu to select diff names
strFormulas(1) = "=SUM(C2:E2)"
strFormulas(2) = "=XLOOKUP(A2,Lists!C:C,Lists!B:B,0,0)"
strFormulas(3) = "=J2*I2"
.Range("I2:K" & Lastrow).Formula = strFormulas
End With
With Worksheets("JBP")
For i = 2 To Lastrow
If .Range("J" & i).Value < .Range("B" & i).Value Then
.Range("J" & i).Font.Color = vbRed
Else
.Range("J" & i).Font.Color = vbBlack
End If
Next i
End With
End Sub