Custom Data Validation - How to call a VBA Subroutine

jimfernish

New Member
Joined
May 29, 2018
Messages
1
Overview:
Create a worksheet that allows employees to track their hours worked each day. Before allowing time entries, verify the user has entered their Name, Number and a Pay period date. After verifying the (3) fields have been filled, validate the time entry and round to the nearest 15 minute interval. Allow the user to enter;

  • 8a convert this cell value to 0800, display the entry as 8:00am
  • 812a convert this cell value to 0815, display the entry as 8:15am
  • 12p convert this cell value to 1200, display the entry as 12:00pm
  • 105p convert this cell value to 1300, display the entry as 1:00pm
  • 455p convert this cell value to 1700, display the entry as 5:00pm
  • 1700 complete the other validations, display the entry as 5:00pm

Goal:
After the user enters data into a cell, use Data Validation to call a Visual Basic subroutine. My thoughts are to use the ActiveCell.Value;

  • Verify Name, Number & Date cells are filled
  • Use ActiveCell.Value and verify time entry is a true time entry and manipulate the cell value as needed.
  • If any of the (3) cells are not filled, return an error box with the missing item message.
  • If the time entry is not valid, return an error box with “invalid time entry” message
  • Return the updated ActiveCell.Value with the manipulated value to the active cell in the worksheet, if time is valid.

Questions:

  • Is it possible to create a function that call the subroutine, validates and returns the manipulated cell contents?
  • Are there any examples of the Functions & Subroutines?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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