VBA - Change Data Validation drop down value based on a value

ChrisMac1

New Member
Joined
Jul 15, 2024
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi there, and thanks for looking at my issue for me.

I have a workbook that has a sheet called DATA. On that sheet I want a code that will revise the data validation dropdown value in column AH from it's blank default to EASY WIN, but only if the value in column B says NO SHOW and the date value in column S is +60 days from today.

I hope I have explained that ok and that this has an easy solution.

Many thanks,
Chris Mac
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
Sorry, the doc has confidential data in so I cannot provide a copy. I can create a dummy doc if that would help?
 
Upvote 0
The dummy doc is fine as long as the data is organized in exactly the same way as in the original.
 
Upvote 0
Thanks for the speedy response mumps, and FYI I am in the UK, in case that makes any difference to anything :)

Unfortunately, due to restrictions on my work laptop I cannot install new apps and cannot access certain sites, including DropBox. Best I can do is a lame screen shot, which is rubbish I know.

So looking at the DATA sheet, when the macro runs it would scan all entries from row 2 to row 100000, checking for any example of a NO SHOW in column B. If a NO SHOW is found the macro would look at the date in column S of that row. If the date is 60 days or older the macro would revise the entry in the data validation option in column AH to be EASY WIN.

On my doc, the only row that would change would be in row 2.

I hope that helps, sorry, all a bit new to this so please do shout if I'm not making sense.
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    66.6 KB · Views: 6
Upvote 0
Alternatively, for not to mess with Data Validation, this could be achieved with DropDowns. If that fits you, I can write the code.
 
Upvote 0
Alternatively, for not to mess with Data Validation, this could be achieved with DropDowns. If that fits you, I can write the code.
Hi Sektor, and thanks for the help here. Ideally I just want to update the option in column AH to show EASY WIN. The Data Validation is built and then copied to other sheets so has to be there.
 
Upvote 0
What is the current data validation rule(s) for col AH?
 
Upvote 0
Try:
VBA Code:
Sub ChangeDV()
    Application.ScreenUpdating = False
    Dim v As Variant, v2 As Variant, i As Long
    v = Range("B2", Range("B" & Rows.Count).End(xlUp)).Resize(, 18).Value
    For i = LBound(v) To UBound(v)
        If v(i, 1) = "NO SHOW" And v(i, 18) < Date - 60 Then
            Range("AH" & i + 1) = "EASY WIN"
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try:
VBA Code:
Sub ChangeDV()
    Application.ScreenUpdating = False
    Dim v As Variant, v2 As Variant, i As Long
    v = Range("B2", Range("B" & Rows.Count).End(xlUp)).Resize(, 18).Value
    For i = LBound(v) To UBound(v)
        If v(i, 1) = "NO SHOW" And v(i, 18) < Date - 60 Then
            Range("AH" & i + 1) = "EASY WIN"
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
Thanks mumps, standby, just testing it...
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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