Conditional Formatting on Variable range

Paraboot

New Member
Joined
Dec 1, 2016
Messages
3
Good morning,

I am trying to make a VBA code to check if the out time has been filled in if there was an in time. If the out time has been left blank the 2 cells need to become yellow when afterwards the cell gets filled in by the user the color needs to disappear. Therefor I am trying to use Conditional formatting in my VBA code but I can't seem to get it working.
this is the code I use so far:

Code:
Set v_laatstecel = [b65536].End(xlUp)
    Set v_gebied = Range([b5], v_laatstecel)
    For Each v_cel In v_gebied
        Set v_in = v_cel.Offset(0, 6) 'in times
        Set v_uit = v_cel.Offset(0, 7) 'out times
        If IsEmpty(v_in) Then
           
        Else
            If IsEmpty(v_uit) Then
                v_uur = v_in.Value
                v_in = v_date - 1 & " " & v_uur
                v_rij = v_cel.Row
                Range(v_in, v_uit).FormatConditions.Add Type:=xlExpression, Formula1:="=ISBLANK(" & v_uit & ")"
                With Selection.FormatConditions(1)
                    .Interior.Color = 36
                    .StopIfTrue = True
                End With

could anybody help with this?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,214,548
Messages
6,120,146
Members
448,948
Latest member
spamiki

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