Advanced Conditional Format in 1 Click - Excel Macro for Beginner

preview_player
Показать описание
New course Launched! I created it to show you step-by-step how to design a salary structure with regression analysis in Excel. Check out the detail here:

Scenario: You want to conditional format based on relative value, not absolute value in 1 click

Function: Macro

***Macro Codes***
IMPORTANT NOTICE: Angle brackets aren't allowed in description. Alternative replacement is noted in the comment.

Sub ConditionalFormat1()
Dim i As Integer
ActiveSheet.Activate

For i = 10 To 20
If Range("G" & i) = Range("F" & i) Then
Range("G" & i + 1).Select
'1st Criteria of Red text color
Else: Range("G" & i).Font.Color = vbRed
End If
Next

End Sub
____________________________________________________
Sub ConditionalFormat2()
Dim i As Integer
ActiveSheet.Activate

For i = 10 To 20
If Range("G" & i) LESS THAN= Range("F" & i) Then
Range("G" & i + 1).Select
'2nd Criteria of Yellow fill color
Else: Range("G" & i).Interior.Color = vbYellow
End If
Next

End Sub
____________________________________________________
Sub ConditionalFormat3()
Dim i As Integer
ActiveSheet.Activate

For i = 10 To 20
If Range("F" & i) NOT EQUAL TO 0 Then
Range("G" & i + 1).Select
ElseIf Range("F" & i) = 0 And Range("G" & i) = 0 Then
Range("G" & i + 1).Select
'3rd Criteria of Black border color
Else:
'when Fi = 0 and Gi NOT EQUAL TO 0
Range("G" & i).BorderAround Color:=vbBlack, Weight:=xlThick
End If
Next

End Sub
____________________________________________________
Sub ConditionalFormat()
Dim i As Integer
ActiveSheet.Activate

For i = 10 To 20
If Range("G" & i) = Range("F" & i) Then
Range("G" & i + 1).Select
'1st Criteria of Red text color
Else: Range("G" & i).Font.Color = vbRed
End If
Next

For i = 10 To 20
If Range("G" & i) LESS THAN= Range("F" & i) Then
Range("G" & i + 1).Select
'2nd Criteria of Yellow fill color
Else: Range("G" & i).Interior.Color = vbYellow
End If
Next

For i = 10 To 20
If Range("F" & i) NOT EQUAL TO 0 Then
Range("G" & i + 1).Select
ElseIf Range("F" & i) = 0 And Range("G" & i) = 0 Then
Range("G" & i + 1).Select
'3rd Criteria of Black border color
Else: 'when Fi = 0 and Gi NOT EQUAL TO 0
Range("G" & i).BorderAround Color:=vbBlack, Weight:=xlThick
End If
Next
End Sub
____________________________________________________

******Follow-up Consulting Services******

******More Videos in Playlists******

#ExcelforHR#HRAnalytics#Excel#HR
Рекомендации по теме
Комментарии
Автор

***Macro Codes***
IMPORTANT NOTICE: Angle brackets aren't allowed in description. So "<>" is replaced with "NOT EQUAL TO"; "<" is replaced with "LESS THAN", ">" is replaced with "GREATER THAN".

CariprosHRAnalytics
Автор

Why did you do the Range("G"&i+1).Select ? Isn't that unnecessary?

jaimecardenascervantes
join shbcf.ru