For...Next with drop down lists

wwbwb

Well-known Member
Joined
Oct 20, 2003
Messages
513
Greetings:

In a production reporting spreadsheet, users fill in their daily activities via drop downs.
b5:b25 contains drop downs listing areas worked.
c5:c25 contains drop downs listing activities.

One of the areas in the drop down is Leave_Snack.
There are 5 activities associated with this area.

What they are supposed to do is when they select Leave_Snack, is to also include the activity. (Snack/Cleanup, Leave Other, Leave Family...etc)
Sometimes they forget.

When the form is submited (basically copied and saved to a different sheet), I want a warning to pop up saying that they forgot to put an activity with their Leave_Snack.

I put this at the beginning of the submit code, but it doesn't seem to recognize anything from a dropdown list. Am I missing something?

Code:
Dim mycell As Range
Dim myrange As Range

Set myrange = Range("b5:b25")

For Each mycell In myrange
 If Range(mycell).Value = "Leave_Snack" Then
  If Range(mycell).Offset(, 1).Value = "" Then GoTo error2
 End If
Next
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,413
Maybe...

Code:
Dim mycell As Range
Dim myrange As Range
Set myrange = Range("b5:b25")
For Each mycell In myrange
    If mycell.Value = "Leave_Snack" Then
        If mycell.Offset(, 1).Value = "" Then GoTo error2
    End If
Next
'more code

M.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,141
Messages
5,599,966
Members
414,352
Latest member
macquarie_jchan58

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
Top