DV or CF Formula?

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,113
Office Version
  1. 365
Platform
  1. Windows
Good Day All,

I'm working with a database, between Columns E & F.

Column E has a numerical tally and Column F has an associated weight.

I'm looking to create a formula through DV or CF that when a numerical entry is made into Column E that its corresponding Column F if blank will highlight red with the words "Enter KG!".

Likewise, when a numerical entry made is made into Column F and Column E is blank that its cell highlights red with the words "Enter Tally".

If both cells of the corresponding Columns E & F are blank then nothing happens.

Not sure which would be the more stable action to take, either through DV or CF?

But I'd like to definitely stay away from the VBA approach.

Anyone can help? I'm all ears.

Thank you!
Pinaceous






Capture1.PNG
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Neither DV or CF can do what you want. You would need to use VBA. Is that an option?
 
Upvote 0
Neither DV or CF can do what you want. You would need to use VBA. Is that an option?
Good Day dreid1011,

What if I do not want the "Text" to appear in the opposite cell and to just highlight red?

Would I be able to work with DV or CF?

Thanks,
pinaceous
 
Upvote 0
Yes, if you just wanted to highlight red, then a couple CF formulas would work. I also have some VBA written up if you want what you originally asked for.
 
Upvote 0
Here are the CF rules:
Book1
EF
105
115
125
135
145
155
164
174
183
193
201
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F10:F20Expression=AND(F10="",E10<>"")textNO
E10:E20Expression=AND(E10="",F10<>"")textNO

Book1
EF
1050
115
125
135
1475
155
1644
174
183
193
201
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F10:F20Expression=AND(F10="",E10<>"")textNO
E10:E20Expression=AND(E10="",F10<>"")textNO


And here is the VBA option:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim fCell As Range, eCell As Range

If Not Intersect(Target, Range("E10:F20")) Is Nothing Then
    Application.EnableEvents = False
   
    If Target.Column = 5 Then Set fCell = Target.Offset(0, 1)
    If Target.Column = 6 Then Set eCell = Target.Offset(0, -1)
   
    Select Case Target.Column
        Case 5
            If fCell.Value = "" Then
                fCell.Value = "Enter KG!"
                fCell.Interior.ColorIndex = 3
            End If
            If Target.Value <> "Enter Tally" Then Target.Interior.ColorIndex = xlNone
        Case 6
            If eCell.Value = "" Then
                eCell.Value = "Enter Tally"
                eCell.Interior.ColorIndex = 3
            End If
            If Target.Value <> "Enter KG!" Then Target.Interior.ColorIndex = xlNone
        Case Else
            GoTo Breakout
    End Select
   
Breakout:
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Thanks!

In using the CF approach, How would I access the menu "Cells with Conditional Formatting" as you have posted?

The first menu of CF appears, then the second menu appears below.

Please explain and thanks!


Capture1.PNG


Capture2.PNG
 
Upvote 0
Select a range in column E, E10:E20 for example, then go to Conditional Formatting > New Rule. Select "Use a formula to determine which cells to format" and type in the following formula:
=AND(E10="",F10<>"")
Click Format and select the Fill tab and pick your color.

Repeat these steps with a range selected in column F, and enter the following formula:
=AND(F10="",E10<>"")

1710540434659.png
 

Attachments

  • 1710540427413.png
    1710540427413.png
    15.3 KB · Views: 3
Upvote 1
Solution

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top