I Need Help To Do This Code In A Macro

  • Thread starter Thread starter dpjim
  • Start date Start date
D

dpjim

If need help make this code in a macro !!

. Variable CLI - Macro

BR = Business Relevance
n-r = non-relevant

-----------------------------------------------------------
IF BR = “n-r” THEN
BEGIN (1)
If KI < 1.5 then
begin
write “CLS 11”
write “overqualified”
SelectColor = Turquise
end

else if 1.5 <= KI < 2.5 then
begin
write “CLS 12”
write “overqualified”
SelectColor = Turquise
end

else if 2.5 <= KI then
begin
write “CLS 13”
write “overqualified”
SelectColor = Turquise
end
END (1)
-----------------------------------------------------------

ELSE IF BR = “medium” THEN
BEGIN (2)
If KI < 1.5 then
begin
write “CLS 04”
write “OK”
SelectColor = Bright Green
end

else if 1.5 <= KI < 2.5 then
begin
write “CLS 05”
write “OK”
SelectColor = Bright Green
end

else if 2.5 <= KI then
begin
write “CLS 16”
write “overqualified”
SelectColor = Turquise
end
END (2)
-----------------------------------------------------------


ELSE IF BR = “high” THEN
BEGIN (3)
If KI < 1.5 then
begin
write “CLS -27”
write “critical”
SelectColor = Red
end

else if 1.5 <= KI < 2.5 then
begin
write “CLS -18”
write “needs improvement”
SelectColor = Light Yellow
end

else if 2.5 <= KI then
begin
write “CLS 09”
write “OK”
SelectColor = Bright Green
end
END (3)
-----------------------------------------------------------

ELSE
BEGIN (4)
write “ERROR”
END (4
 
Not exactly sure about the content, but this shows the basic structure
The indendation helps here.:-

Code
-------------------

Sub untested()
' TO SHOW CODE STRUCTURE ONLY
Dim MyCell As Range
MyCell = ActiveSheet.Range("A1")
'-------------------------------------------------
Select Case BR
Case Is = "n - r"
If KI < 1.5 Then
MyCell.Value = "CLS 11" & " overqualified"
MyCell.Interior.ColorIndex = 42
ElseIf 1.5 <= KI < 2.5 Then
MyCell.Value = "CLS 12" & " overqualified"
MyCell.Interior.ColorIndex = 42
ElseIf 2.5 <= KI Then
MyCell.Value = "CLS 13" & " overqualified"
MyCell.Interior.ColorIndex = 42
End If
Case Is = "medium"
If KI < 1.5 Then
MyCell.Value = "CLS 11" & " overqualified"
MyCell.Interior.ColorIndex = 42
ElseIf 1.5 <= KI < 2.5 Then
MyCell.Value = "CLS 12" & " overqualified"
MyCell.Interior.ColorIndex = 42
ElseIf 2.5 <= KI Then
MyCell.Value = "CLS 13" & " overqualified"
MyCell.Interior.ColorIndex = 42
End If
Case Is = "high"
If KI < 1.5 Then
MyCell.Value = "CLS 11" & " overqualified"
MyCell.Interior.ColorIndex = 42
ElseIf 1.5 <= KI < 2.5 Then
MyCell.Value = "CLS 12" & " overqualified"
MyCell.Interior.ColorIndex = 42
ElseIf 2.5 <= KI Then
MyCell.Value = "CLS 13" & " overqualified"
MyCell.Interior.ColorIndex = 42
End If
End Select
End Sub

-------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top