Only select value according to highlighted cells

lewisthelemon

New Member
Joined
Dec 5, 2018
Messages
4
Hello, I am trying a code which would select a value from a Data Validation Dropdown list only if the cell which is two blocks to its left is highlighted.

I have the following code which is wrong but just as an example:

Code:
Sub AssignBided()


Worksheets("Monday").Select
With Worksheets("Monday")
    If Hilight.range("B12") = True Then
        range("B12").Activate
        ActiveCell.Offset(0, -2).Select
        .Selection.Value = "ABC"
    End If
End With
End Sub

The code to highlight cells is as follows:

Code:
Sub Hilight(RNG As range, Hilight As Boolean)
    With RNG.Interior
        If Hilight Then
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = RGB(100, 250, 150)
            .TintAndShade = 0
            .PatternTintAndShade = 0
        Else
            .Pattern = xlNone
            .PatternTintAndShade = 0
        End If
    End With
End Sub

This Sub is used as follows:

Code:
Dim L8Product As String


Dim i As Long
Dim L8Rnge As range


L8Product = range("Line8_P_Mon")
'Line 8 Resource requirement code


'Determine if change was made in cell B39
If Not Intersect(Target, Me.range("Line8_P_Mon, Line11_P_Mon, Line12_P_Mon, Line10_P_Mon")) Is Nothing Then
        Hilight range("Line8_Hilight_Mon, Line11_Hilight_Mon, Line12_Hilight_Mon, Line10_Hilight_Mon, Prep_Hilight_Mon"), False
'Below Code searches in the KP and Osgood Table and then highlights the appropriate cells
    If Trim(L8Product) <> "" Then
        With Sheets("Products").range("KP_Table")                     'searchs in the KP Table on Sheet Overtime_Pos_Table
            
            'The code below will search the KP table for the product that you will select from the Line 8 drop down
            Set L8Rnge = .Find(what:=L8Product, _
                            after:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            lookat:=xlWhole, _
                            searchorder:=xlByRows, _
                            searchdirection:=xlNext, _
                            MatchCase:=False)
            If Not L8Rnge Is Nothing Then
                    Hilight range("KP_Hilight_Mon"), True               'Hilights the cells for the KP and the Prep material required
            Else: With Sheets("Products").range("Osgood_Table")
                    Set L8Rnge = .Find(what:=L8Product, _
                                    after:=.Cells(.Cells.Count), _
                                    LookIn:=xlValues, _
                                    lookat:=xlWhole, _
                                    searchorder:=xlByRows, _
                                    searchdirection:=xlNext, _
                                    MatchCase:=False)
                    If Not L8Rnge Is Nothing Then
                            Hilight range("Osgood_Hilight_Mon"), True   'Hilights the cells for the Osgood and the Prep material required
                    End If
                  End With
            End If
        End With
    Else: Hilight range("Line8_Hilight_Mon"), False
    End If
End If


Thanks in advance. Been trying this for a long time now :)
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,214,589
Messages
6,120,416
Members
448,960
Latest member
AKSMITH

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